File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ var puzzles = map[helpers.Puzzle]helpers.Solver{
2727 helpers.Puzzle {2024 , 2 }: y2024 .New02 (),
2828 helpers.Puzzle {2024 , 3 }: y2024 .New03 (),
2929 helpers.Puzzle {2024 , 17 }: y2024 .New17 (),
30+ helpers.Puzzle {2025 , 1 }: y2025 .New01 (),
3031 helpers.Puzzle {2025 , 2 }: y2025 .New02 (),
3132}
3233
Original file line number Diff line number Diff line change 1+ package y2025
2+
3+ import (
4+ "strconv"
5+ "strings"
6+
7+ "isaacgood.com/aoc/helpers"
8+ )
9+
10+ // Day01 solves 2025/01.
11+ type Day01 struct {
12+ turns [][2 ]int
13+ }
14+
15+ // New01 returns a new solver for 2025/01.
16+ func New01 () * Day01 {
17+ return & Day01 {}
18+ }
19+
20+ // SetInput handles input for this solver.
21+ func (p * Day01 ) SetInput (data string ) {
22+ for line := range strings .SplitSeq (data , "\n " ) {
23+ turn := helpers .Atoi (line [1 :])
24+ step := 1
25+ if line [0 ] == 'L' {
26+ step = - 1
27+ }
28+ p .turns = append (p .turns , [2 ]int {turn , step })
29+ }
30+ }
31+
32+ // Solve returns the solution for one part.
33+ func (p * Day01 ) Solve (part int ) string {
34+ var clicks uint64
35+ position := 50
36+ for _ , turn := range p .turns {
37+ step := turn [1 ]
38+ for i := 0 ; i < turn [0 ]; i ++ {
39+ position += step
40+ if position % 100 == 0 && part == 1 {
41+ clicks ++
42+ }
43+ }
44+ if position % 100 == 0 && part == 0 {
45+ clicks ++
46+ }
47+ }
48+ return strconv .FormatUint (clicks , 10 )
49+ }
You can’t perform that action at this time.
0 commit comments