checking my old answer

main
Sam Hatfield 3 years ago
parent 8a9bca7c97
commit c0a22df7c9
Signed by: sehqlr
GPG Key ID: 6B1E0EDE1530CA2B

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

Loading…
Cancel
Save