a02391702d
another bruteforce, but this one is actually fast so I really don’t care
17 lines
396 B
Haskell
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..]
|