Solve day 3, part 2

pull/1/head
Gaël Depreeuw 4 years ago
parent a9b566e9ad
commit 40c5f7b10f
Signed by: Mithror
GPG Key ID: 8AB218ABA4867F78
  1. 10
      src/Day3.hs

@ -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

Loading…
Cancel
Save