File tree Expand file tree Collapse file tree 2 files changed +21
-6
lines changed
Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change 2121-- solution. You can delete the type signatures completely and GHC
2222-- will recommend what should go in place of the underscores.
2323module AOC2025.Day06 (
24- -- day06a,
25- -- day06b
24+ day06a ,
25+ day06b
2626
2727)
2828where
@@ -55,19 +55,29 @@ day06a =
5555 MkSol
5656 { sParse =
5757 noFail $
58- lines
58+ map reverse . transpose . map words . lines
5959 , sShow = show
6060 , sSolve =
6161 noFail $
62- id
62+ sum . map go
6363 }
64+ where
65+ go (" *" : xs) = product $ map read xs
66+ go (" +" : xs) = sum $ map read xs
6467
6568day06b :: _ :~> _
6669day06b =
6770 MkSol
68- { sParse = sParse day06a
71+ { sParse = noFail $
72+ splitWhen (all isSpace) . transpose . lines
6973 , sShow = show
7074 , sSolve =
7175 noFail $
72- id
76+ sum . map go
7377 }
78+ where
79+ go (x: xs) = case last x of
80+ ' *' -> product $ map read (init x : xs)
81+ ' +' -> sum $ map read (init x : xs)
82+
83+ -- 14, 148
Original file line number Diff line number Diff line change 1+ 123 328 51 64
2+ 45 64 387 23
3+ 6 98 215 314
4+ * + * +
5+ >>> 3263827
You canβt perform that action at this time.
0 commit comments