diff options
author | Crazazy | 2024-12-01 14:15:18 +0100 |
---|---|---|
committer | Crazazy | 2024-12-01 14:15:18 +0100 |
commit | 5ba0d95a80c06a39e65abc52200ee2fd7ee90bda (patch) | |
tree | 5793633e2fa7bcb859ffdcf406bc09ea8bfb6e5f /src/Day1.idr | |
parent | 911796e471b30f7b1d8358e9d9d179852cfebfc5 (diff) |
made some AoC infrastructure
Diffstat (limited to 'src/Day1.idr')
-rw-r--r-- | src/Day1.idr | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/Day1.idr b/src/Day1.idr index 96cf777..e29b0a7 100644 --- a/src/Day1.idr +++ b/src/Day1.idr @@ -27,9 +27,10 @@ occur x fs = foldr (\y => \r => if x == y then r + 1 else r) 0 fs part2 : (List Int, List Int) -> Int part2 (l1, l2) = sum $ map (\x => x * (occur x l2)) l1 -main : IO () -main = do - estr <- readFile "data/day1.txt" - str <- either (die . show) pure estr - putStrLn $ show $ part1 $ unzip $ parseStr str - putStrLn $ show $ part2 $ unzip $ parseStr str +export +sol1 : String -> String +sol1 = show . part1 . unzip . parseStr + +export +sol2 : String -> String +sol2 = show . part2 . unzip . parseStr |