Advent of Code 2025 — Day 01

Language: Rust

Problem https://adventofcode.com/2025/day/1


Day 1 is a straightforward warmup. The input consists of instructions like L68 or R14. Parsing this in Rust is simple: the first character gives the direction, and the rest of the string parses into an integer.

let dir: char = instruction.chars().nth(0).unwrap();
let value: i32 = instruction[1..].parse().unwrap();

The dial starts at 50. Each instruction moves it left or right, and because the dial wraps between 0 and 99, the value must always be normalized. Rust’s % operator can produce negative results, so a Euclidean remainder is used.

dial = ((dial % 100) + 100) % 100;

Part 1: Apply each instruction, normalize the dial, and count how many times it ends up exactly at 0.


Part 2: The dial starts at 50, and a counter tracks how many times it passes through 0.

For a right turn (R), every wrap from 99 back to 0 counts as a crossing. This can be counted directly using (dial + value) / 100, then the dial is wrapped back into range.

Left turns (L) are a bit trickier. What matters is how far the dial is from zero. If the dial is at 0, turning left wraps immediately, so it’s treated as being 100 steps away. If the rotation is large enough to reach zero, that’s one crossing, and every full loop after that adds another one. The dial is then updated and wrapped as usual.

The counter ends up holding the total number of times the dial crosses zero.


Solution: https://github.com/Elyrial/AdventOfCode/blob/main/src/solutions/year2025/day01.rs

Approach (C)

Explain it.

DRAFTED