day6
another bruteforce, but this one is actually fast so I really don’t care
This commit is contained in:
parent
3271b1f2a5
commit
a02391702d
|
@ -0,0 +1,16 @@
|
|||
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..]
|
|
@ -0,0 +1,2 @@
|
|||
Time: 59 68 82 74
|
||||
Distance: 543 1020 1664 1022
|
|
@ -0,0 +1,2 @@
|
|||
Time: 7 15 30
|
||||
Distance: 9 40 200
|
Loading…
Reference in New Issue
Block a user