We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f056a2c commit f71c6a8Copy full SHA for f71c6a8
day07/src/Day07.curry
@@ -18,11 +18,11 @@ isSolvable ops = notEmpty . set1 isSolvable'
18
where
19
isSolvable' (Equation l (r:rs)) | l =:= evalAcc r rs = True
20
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
+ evalAcc acc vals = case vals of
+ -- Prune branches that already overshoot the target
+ _ | acc > l -> failed
+ [] -> acc
+ (v:vs) -> anyOf $ (\op -> evalAcc (op acc v) vs) <$> ops
26
27
totalResult :: [Int -> Int -> Int] -> [Equation] -> Int
28
totalResult ops eqns = sum $ lhs <$> filter (isSolvable ops) eqns
0 commit comments