another bruteforce, but this one is actually fast so I really don’t care
This commit is contained in:
Gattix 2023-12-06 14:49:53 +01:00
parent 3271b1f2a5
commit a02391702d
3 changed files with 20 additions and 0 deletions

16
2023/day06/day06.hs Normal file
View File

@ -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..]

2
2023/day06/input Normal file
View File

@ -0,0 +1,2 @@
Time: 59 68 82 74
Distance: 543 1020 1664 1022

2
2023/day06/testinput Normal file
View File

@ -0,0 +1,2 @@
Time: 7 15 30
Distance: 9 40 200