Advent of Code solutions

2025 day 1

+15
+4
2025/1/p1.hs
··· 1 + rotate rot ('L' : dist) = (rot - (read dist `mod` 100) + 100) `mod` 100 2 + rotate rot ('R' : dist) = (rot + read dist) `mod` 100 3 + 4 + main = getContents >>= print . length . filter ((==) 0) . scanl rotate 50 . lines
+11
2025/1/p2.hs
··· 1 + rotate (count, rot) ('L' : dist) = rotate_ count rot (-read dist) 2 + rotate (count, rot) ('R' : dist) = rotate_ count rot (read dist) 3 + 4 + rotate_ count rot dist = (count2, rot2) 5 + where 6 + rotations = abs dist `div` 100 7 + crossed = not $ (rot + dist `rem` 100) `elem` [0 .. 99] 8 + count2 = count + rotations + if crossed then 1 else 0 9 + rot2 = (rot + (dist `rem` 100) + 100) `rem` 100 10 + 11 + main = getContents >>= print . fst . foldl rotate (0, 50) . lines