Advent of Code 2025

Day 1

Changed files
+25 -3
src
+1 -1
input.sh
···
#!/bin/bash
-
YEAR=2024
+
YEAR=2025
DAY=$1
COOKIE=$(cat cookie.txt)
+24 -2
src/Day1.hs
···
module Day1 where
+
parseLine :: String -> (Char, Int)
+
parseLine (c : s) = (c, read s)
+
+
parseInput :: String -> [(Char,Int)]
+
parseInput input = map parseLine $ lines input
+
+
doRotations :: [(Char, Int)] -> Int -> [Int]
+
doRotations (('L', l) : rest) n = (n : doRotations rest ((n-l) `mod` 100))
+
doRotations (('R', r) : rest) n = (n : doRotations rest ((n+r) `mod` 100))
+
doRotations [] n = [n]
+
+
getCrossings :: [(Char, Int)] -> Int -> [Int]
+
getCrossings (('L', l) : rest) n = (((l-n) `div` 100) + (if n > 0 then 1 else 0) : getCrossings rest ((n-l) `mod` 100))
+
getCrossings (('R', r) : rest) n = (((n+r) `div` 100) : getCrossings rest ((n+r) `mod` 100))
+
getCrossings [] _ = []
+
part1 :: String -> String
-
part1 _ = "Day 1 part 1"
+
part1 input =
+
let rotations = parseInput input
+
states = doRotations rotations 50
+
in show $ length (filter (== 0) states)
part2 :: String -> String
-
part2 _ = "Day 1 part 2"
+
part2 input =
+
let rotations = parseInput input
+
zeroCrossings = getCrossings rotations 50
+
in show $ sum zeroCrossings