@@ 29,16 29,17 @@ parser = do
ds <- many $ int <* spaces
return $ zip ts ds
+naive (t, r) = length $ filter (>r) $ take (t+1) [0..] <&> \h -> h * (t - h)
+
partA :: Parse -> Int
-partA rs = foldr (*) 1 $ fmap f rs
- where f (t, r) = length $ filter (>r) $ take (t+1) [0..] <&> \h -> h * (t - h)
+partA rs = foldr (*) 1 $ fmap naive rs
---partB :: Parse -> Parse
---partB = id
+partB :: Parse -> Int
+partB rs = naive $ (\(t, d) -> (read t, read d)) $ foldr (\(t1, d1) (t0, d0) -> (t1++t0, d1++d0)) ("", "") $ fmap (\(t, d) -> (show t, show d)) rs
main :: IO ()
main = with parser $ do
run "06.example" "a example" partA
run "06.input" "a input" partA
- --run "06.example" "b example" partB
- --run "06.input" "b input" partB
+ run "06.example" "b example" partB
+ run "06.input" "b input" partB