AoC/2023/day06/day06.hs
Gattix a02391702d day6
another bruteforce, but this one is actually fast so I really don’t care
2023-12-06 14:49:53 +01:00

17 lines
396 B
Haskell

import Data.List
main :: IO ()
main = do
input <- parse <$> readFile "input"
print $ product $ map race input
print $ race (p2ify input)
parse :: String -> [[Int]]
parse = transpose . map (map read . tail . words) . lines
p2ify :: [[Int]] -> [Int]
p2ify = map (read . concatMap show) . transpose
race :: [Int] -> Int
race [x,y] = length $ filter (>y) $ zipWith (*) [0..x] [x, pred x..]