Here's my beginner's Haskell solution:
ans1 :: [String] -> Int -> Int -> Int ans1 inp right down = length $ filter (\(ind, row) -> ind `mod` down == 0 && row !! (ind `div` down * right `mod` length row) == '#') $ zip [0..] inp ans2 :: [String] -> [(Int, Int)] -> Int ans2 inp = product . map (uncurry (ans1 inp)) main :: IO () main = do contents <- readFile "adventofcode3.input" print $ ans1 (lines contents) 3 1 print $ ans2 (lines contents) [(1, 1), (3, 1), (5, 1), (7, 1), (1, 2)]
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Here's my beginner's Haskell solution: