Skip to content

Commit f71c6a8

Browse files
committed
Merge everything into one case expression
1 parent f056a2c commit f71c6a8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

day07/src/Day07.curry

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ isSolvable ops = notEmpty . set1 isSolvable'
1818
where
1919
isSolvable' (Equation l (r:rs)) | l =:= evalAcc r rs = True
2020
where
21-
-- Prune branches that already overshoot the target
22-
evalAcc acc vals | acc > l = failed
23-
| otherwise = case vals of
24-
[] -> acc
25-
(v:vs) -> anyOf $ (\op -> evalAcc (op acc v) vs) <$> ops
21+
evalAcc acc vals = case vals of
22+
-- Prune branches that already overshoot the target
23+
_ | acc > l -> failed
24+
[] -> acc
25+
(v:vs) -> anyOf $ (\op -> evalAcc (op acc v) vs) <$> ops
2626

2727
totalResult :: [Int -> Int -> Int] -> [Equation] -> Int
2828
totalResult ops eqns = sum $ lhs <$> filter (isSolvable ops) eqns

0 commit comments

Comments
 (0)