|
|
|
@ -13,7 +13,7 @@ main :: IO ()
|
|
|
|
|
main = do
|
|
|
|
|
input <- TIO.readFile "input.txt"
|
|
|
|
|
let theMap = treeMap $ map T.unpack $ T.lines input
|
|
|
|
|
let trajectories = map (trajectory theMap) slopes
|
|
|
|
|
let trajectories = map (trajectory theMap) $ [head slopes]
|
|
|
|
|
let hits = map (map (hitTree theMap)) trajectories
|
|
|
|
|
|
|
|
|
|
let answer = product $ map sum $ map (map (\x -> if x then 1 else 0)) hits
|
|
|
|
@ -33,7 +33,7 @@ hitTree :: [[Bool]] -> (Int, Int) -> Bool
|
|
|
|
|
hitTree bbs (x, y) = (bbs !! x) !! y
|
|
|
|
|
|
|
|
|
|
slopes :: [(Int, Int)]
|
|
|
|
|
slopes = [(1,1),(1,3),(1,5),(1,7),(2,1)]
|
|
|
|
|
slopes = [(1,3),(1,1),(1,5),(1,7),(2,1)]
|
|
|
|
|
|
|
|
|
|
trajectory :: [[Bool]] -> (Int, Int) -> [(Int, Int)]
|
|
|
|
|
trajectory theMap (x,y) = tobogganLocations (x,y) (x,y) (length theMap, length $ head theMap)
|
|
|
|
|