module Main where main :: IO () main = do n <- lines <$> readFile "input/03" print $ countTrees 3 1 n print $ product [ countTrees 1 1 n , countTrees 3 1 n , countTrees 5 1 n , countTrees 7 1 n , countTrees 1 2 n ] countTrees :: Int -> Int -> [String] -> Int countTrees right down ls = go (map cycle ls) where go [] = 0 go remaining@(r:rs) = i (head r) + go (map (drop right) (drop down remaining)) where i = fromEnum . (== '#')