This commit is contained in:
pingu 2024-12-02 08:36:57 +01:00
parent c4d8bef5f7
commit 5b1fd043e7

View File

@ -15,15 +15,10 @@ solve1 =
solve2 :: [[Int]] -> Int
solve2 =
let r [] = [[]]
r (r':rs) = rs:((r':) <$> r rs)
di a = all (\a' -> a' < 4 && not (a' <= 0)) a ||
all (\a' -> a' > -4 && not (a' >= 0)) a in
sum . ((\a ->
if any (\b -> di $ zipWith (flip (-)) b (tail b)) a
then 1 else 0) .
r (r':rs) = rs:((r':) <$> r rs) in
sum . ((\a -> if a > 0 then 1 else 0) . solve1 .
r <$>)
main :: IO ()
main = readFile "inputs/2" <&> parse >>= \i ->
print (solve1 i) >>