|
|
|
@ -59,7 +59,13 @@ parseGrid s = |
|
|
|
|
day3 :: IO () |
|
|
|
|
day3 = do |
|
|
|
|
r <- readFile "./input/day3" |
|
|
|
|
let grid = parseGrid r |
|
|
|
|
putStr "[Day 3-1] # trees: " |
|
|
|
|
case slideDown (0, 0) (3, 1) (parseGrid r) (Just []) of |
|
|
|
|
case slideDown (0, 0) (3, 1) grid (Just []) of |
|
|
|
|
Nothing -> putStrLn "ERROR" |
|
|
|
|
Just locs -> print . countTrees $ locs |
|
|
|
|
Just locs -> print . countTrees $ locs |
|
|
|
|
putStr "[Day 3-2] # trees: " |
|
|
|
|
let mTrees = mapM (\x -> slideDown (0, 0) x grid (Just [])) [(1, 1), (3, 1), (5, 1), (7, 1), (1, 2)] |
|
|
|
|
case mTrees of |
|
|
|
|
Nothing -> putStrLn "ERROR" |
|
|
|
|
Just trees -> print . product $ map countTrees trees |
|
|
|
|