Reuse 1
This commit is contained in:
parent
c4d8bef5f7
commit
5b1fd043e7
9
app/2.hs
9
app/2.hs
@ -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) >>
|
||||
|
Loading…
Reference in New Issue
Block a user