Skip to content

Commit 46fe35d

Browse files
committed
Solve 2025 day 10 part 1
1 parent ef43e54 commit 46fe35d

File tree

3 files changed

+225
-0
lines changed

3 files changed

+225
-0
lines changed
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
[.##.#..##.] (3,6) (0,1,2,3,4,5,7,9) (0,1,5,6,7,8,9) (1,9) (0,1,3,4,5,6,7) (0,1,2,3,4,5) (1,2,3,4,5,6,7,8) (2,3,5,7,8) (2,3,5,7,9) (0,1,2,3,4,6,9) (4,5,6,7,8) (3,6,7,8,9) {52,67,66,109,49,65,70,66,33,72}
2+
[..##.] (2,4) (0,4) (1,3,4) (0,2,3,4) (2,3) {16,2,22,13,29}
3+
[..#.##..] (1,2,3,4,5,6) (0,2,7) (1,2,3) (0,4) (0,1,4,5,6,7) (0,4,5,7) (0,1,2,3,5,7) {35,30,34,20,20,18,10,32}
4+
[#.#.#..##] (0,2,4,5,6,7,8) (0,2,4,8) (0,1,4,5) (3,6,8) (2,6,8) (0,1,2,3,5,6) (0,5,7) (0,3,4,5) (2,4,5,6,8) (0,1,3,5) {78,40,73,52,50,88,79,25,63}
5+
[###..#] (0,1,2,4,5) (0,4,5) (2,3) (1,3) (2,3,4,5) (0,1,4,5) (2,5) {33,38,44,37,46,51}
6+
[.####...#.] (1,2,3,4,8) (0,1,2,3,4,5,6,9) (2,5) (0,4,6,7,9) (0,2,6,7,8) (0,2,6,8,9) (0,1,4,5,6,7,8,9) (1,5,6,9) (1,3) (0,1,2,3,4,7,8,9) (0,1,2,5,7) {57,69,71,46,34,52,43,31,38,52}
7+
[###..#...#] (2,6,7,8) (0,3,7,8,9) (0,8) (5,7) (1,2,5,8) (1,3,6,7) (2,3,4,7,9) (0,1,2,3,6,9) (0,2,4,6,7,8,9) (1,2,3,4,5,6,9) (0,1,4,5,7,9) {54,37,34,27,18,20,28,34,44,38}
8+
[#.##..##] (2,5) (1,3,4,7) (0,2,3,6,7) (0,2,3,4,5,7) (4,5,7) (1,2,3,5,7) (3,6) (0,1,3,4,5,6) (1) {39,42,54,72,44,57,31,51}
9+
[##.#] (3) (0,3) (0,2) (1,3) (0,2,3) {20,6,10,37}
10+
[##..#.] (3,4,5) (1,3,5) (2,4) (0,1,2,3,4,5) {17,131,30,138,37,138}
11+
[.##.#.] (3) (0,3,4,5) (0,1,2,5) (1,4,5) {25,16,8,36,25,33}
12+
[..###.##.] (4,6) (2,4) (0,8) (1,5,6,7,8) (3) (3,7,8) (2,8) (1,2,5) {17,22,22,17,10,22,26,33,66}
13+
[...###.] (1,3,5,6) (0,2,3,4) (0,2,4,5,6) (0,2,5) (0,1,2,3,4) (4,5) {183,25,183,38,44,185,38}
14+
[....#...] (1,2,4,6,7) (0,1,2,6,7) (0,1,2,3,4,5,6) (0,1,3,4,6,7) (2,5,6,7) (1,2,4,5,6,7) (1,3,4,5,6) (4,5) {19,51,30,33,62,45,51,23}
15+
[..#...###] (0,1,4,5,6) (3,4,7,8) (0,6,7) (0,1,4) (0,4,6) (0,1,2,3,6,7,8) (1,2,3,4,7,8) (0,1,5,6,8) {44,37,15,35,50,17,39,45,46}
16+
[#.##..###] (0,5) (1,2,5,7) (0,1,3,4,6) (5,7) (1,4) (1,3,4,5,8) (1,2,4,8) (2,6) (0,1) (0,1,2,3,4,6,7) (3,5,6,7) {172,213,30,32,59,43,17,27,34}
17+
[#..#..] (4) (0,1,3,5) (1,2) (1,2,3,4,5) (0,5) {21,50,30,30,13,31}
18+
[#..##.#.#.] (2,3,4,6,8) (3,4,5,6,7) (3,8,9) (3,5,6,7,9) (0,3,4,5,8) (2,3,5,6,8,9) (1,8) (0,1,2,3,5,6,7,8) (1,2,5,6,8,9) (2) {12,40,30,27,7,35,38,23,44,19}
19+
[.#..#..#..] (0,3) (3,4,5,6,8,9) (0,1,4,5,7,9) (1,3,4,7,9) (0,1,2,3,4,5,7,8,9) (2,6,7) (0,4,6,9) (0,1,4) (3,7,8) {47,37,18,56,63,38,31,45,38,57}
20+
[##.#.###.#] (0,1,4,6,7) (0,1,3,5) (0,3) (1,2,3,5,6,7,8,9) (0,2,3,4,5,6,7,8) (1,4,8) (0,1,7,8,9) (0,1,2,4,5,7,8,9) (2,3,4,5,7,8,9) (1,4) (9) (0,6) (0,1,3,5,6,7,8,9) {106,109,39,74,61,68,67,85,83,56}
21+
[###.] (1,2,3) (0,1,2) {133,145,145,12}
22+
[..###] (0,3) (2) (2,4) (1) (0,1,4) (0,1,2,3) {21,28,32,16,8}
23+
[..#.####.#] (0,1,2,6,7,8,9) (0,7) (0,2,3,4,5,6,7) (0,1,4,5,6) (3,4,5) (0,1,2,3,4,5,8,9) (4,5) (2,4,5,6,7,9) (0,1,2,3,4,5,6,7) (0,1,2,3,4,5,6,9) (8,9) {257,237,81,62,284,284,267,78,39,68}
24+
[#.#.#] (0,3) (0,2,4) (0,1,4) {173,9,163,1,172}
25+
[.#..##...] (8) (0,3,4,5,7,8) (7) (2,8) (5,7) (0,1,3,7,8) (1,4,6,7) (0,3,4,5,7) (0,1,2,5,6,7) (0,2,5,8) (3,5,7,8) {64,35,33,48,38,69,17,82,69}
26+
[##.##.#] (0,1,3,5,6) (2,5) (2,4) (2,3) (0,1,2,3,5,6) {18,18,62,36,17,35,18}
27+
[.###.] (0,1,2,3,4) (1,2,4) (1,2,3) {149,166,166,162,153}
28+
[.#...] (0,1,2,3) (0,4) (1,2,4) (1,3) (2,3,4) {13,39,31,26,24}
29+
[###.####.#] (0,1,2,3,6,7,8,9) (4,5,7,8) (0,1,3,4,5,6,8,9) (0,6,7,8) (0,2,3) (0,1,3,4,5,9) (0,1,6,8) (1,2,3,4,6,7,8,9) (0,2,4,5,7,8,9) (3,5,6,7,8) (0,2,4,6,8) (4,6) {90,47,42,59,59,36,80,38,77,36}
30+
[##..#] (1,2) (0,1,3) (2,4) (1,2,3) (0,1,4) {12,27,22,3,18}
31+
[.##....##.] (2,7) (1,2,6,7,9) (1,2,3,4,6,7,8,9) (0,7,8) (0,2,4,7) (6) (0,1,3,4,5,7,8,9) (1,3,5,7) {37,47,63,27,37,7,54,90,41,41}
32+
[######..#] (1,2,6,7,8) (1,2,5,7,8) (0,1,7,8) (2,3,5,6,7,8) (0,3,4) (0,1,2,4,6,7,8) (0,1,2,5,6,7) {23,19,32,33,17,24,27,38,38}
33+
[...#.#] (3,5) (0,4,5) (0,2,4) (0,1,3) (0,2,3,5) (0,3) (4,5) (1,2,3) {46,22,31,56,18,29}
34+
[....###] (4,5,6) (1,3) (0,3,4,5) (1,2,3,5,6) (2,3,4,5,6) (0,1,2) (1,2,3,4,6) {179,56,51,207,195,198,50}
35+
[##.....] (1,2,4,5) (1,3,4,5) (1,2,3,6) (2,5,6) (0,1,2,6) (0) (0,1,3,4,5,6) (2,3,5) {42,58,64,58,38,69,50}
36+
[##.#.#.] (0,4,6) (0,2,3,4,5) (3,4,5) (0,1,2,3,4) (1,2,5,6) (0,2,3,4,6) (1,2,3,4,5) (2,6) {49,35,64,61,80,54,43}
37+
[#.##] (0,1,3) (1,2,3) (0,1) (1,2) {30,49,19,28}
38+
[##.#.#..##] (0,3,4,5,6,7,8,9) (0,1,2,3,6,8) (3,4,5,6,9) (0,2,3,4,6,8,9) (0,1,2,3,7,8,9) (8,9) (0,1,2,3,4,6,9) (5,7) (5,7,8) (3,6,7,8,9) {64,43,56,86,38,130,68,158,72,74}
39+
[##.#.] (0,1,2,3) (0,1,2,4) (0,1,3) (2) {151,151,28,141,10}
40+
[..##..##] (0,1) (0,1,2,3,4,5,7) (0,2,5,6,7) (0,2,4,7) (0,3,4,5,6,7) (2,3,4,5) (3,4,7) {43,13,44,47,50,53,27,52}
41+
[#..#.##] (1,2) (4,5) (0,2,6) (0,1,2,5) (0,1,3,5,6) (0) (1,2,4,6) (0,3,5,6) {177,50,46,7,26,46,14}
42+
[#.#.] (1) (0) (0,1,3) (2,3) (2) (3) {30,18,11,31}
43+
[####..#...] (4,8) (2,5,8,9) (7,8) (1,2,6,8) (1,2,5,8) (6) (0,2,3,5,6,7,8,9) (1,2,3,5,9) (3,5,6,7,9) (0,1,5) {28,33,50,31,11,65,33,28,58,48}
44+
[##...] (0,1,2,3) (0,1,2,4) (0,2) (0,4) (2,4) {143,133,135,132,9}
45+
[#..#] (1,2,3) (0,2,3) (2,3) (1,2) (0,3) (3) {37,27,56,76}
46+
[###.] (0,1,2) (0,1,3) {25,25,11,14}
47+
[#...#..#] (1,2,3,5,6,7) (0,1,4,5,6,7) (0,2,4) (0,1,3,7) (2,7) (2,3,5,6) (0,5,6,7) (1,4,6,7) (3,5) (0,1,2,4,5,7) {73,210,49,41,203,62,194,228}
48+
[#..##.###.] (6,7,8) (3,5,7) (2,4) (1,3,4,9) (0,1,2,3,6,7,9) (0,1,2,3,5,8) (3,8) (2,3,4,6,7,8,9) (3,4,7,8) (0,1,2,3,4,5,7,8) (0,1,2,4,7) (2,4,6) (5,6,8,9) {41,59,70,115,88,248,237,94,286,230}
49+
[####.#.] (2,3,4,5,6) (0,1,5) (1,5) (4,5) (3,5,6) (0,2,3,4,5,6) (0,1,2,4,5) (1,2,4,5,6) (2,4) {23,38,45,36,52,81,51}
50+
[#.##..#.] (1,3,6,7) (1,2,3) (0,1,3,5,6) (0,1,2,3,4,5,6,7) (2,3,4,6) (1,2,3,4,5,7) {13,55,45,62,33,33,30,36}
51+
[.#.#...#] (2,4,6) (1,2,3,4,5,7) (0,1,4,5,7) (0,1,2,4,5,6) (1,3,4,5,6,7) (1,2,4,5,6,7) (0,1,5,7) (1,3,7) {36,55,41,16,59,54,28,37}
52+
[..##...#..] (0,1,4,5,6,7,8,9) (1,3,5,6,7,8,9) (4,6) (2,3,7) (7) (1,2,3,5,6) (1,5,9) (0,1,8,9) {28,61,21,32,17,49,42,51,39,47}
53+
[..#......] (0,6,7) (4,5,6,7) (0,1,2) (2,3,4,5,7,8) (0,3,5,6,7,8) (3,5,6) (1,2,3,4,5,6,8) {34,23,32,44,26,47,54,37,32}
54+
[#.###] (0,1) (1,2) (1,2,3,4) (0,1,3) (1,2,3) (2,4) {28,62,36,26,15}
55+
[#.#..##..#] (0,3,5,7) (0,6) (1,2,3,9) (2,4,6,7,9) (2,4,8) (0,1,4,5,6,7,8,9) (0,1,3,4,6,7,8,9) (1,2,3,4,5,6,7,8) (2,6) (4,9) {16,21,65,27,69,18,51,40,36,44}
56+
[..##..#] (1,4,6) (0,1,2,3,5) (0,2,4) (3,4) (0,1,2,3,5,6) (4,6) (2,4,5,6) {54,58,66,47,72,50,66}
57+
[#.#..#] (1,2,4) (0,2,4) (0,1,2,3) (2,4) (0,1,4,5) (1,2,3,5) (0,1,2,3,5) {36,61,68,41,37,48}
58+
[.#.#.] (0,1) (4) (1,2,3) (3,4) (2,3,4) (2) {17,37,34,41,35}
59+
[.######..] (0,1,2,5,6,8) (0,5,6) (1,3,4,7) (0,1,3,4,6) (0,4,8) (0,1,3,4,5,7,8) (1,4,5,6,7) (0,1,2,6) (0,2,3,4) {51,58,20,39,54,35,46,30,19}
60+
[#..##] (1,2,4) (1,2) (0,1,2,3) {10,34,34,10,12}
61+
[#.##] (0,2,3) (1,2,3) {13,8,21,21}
62+
[######.#] (1,2,3,4,5,7) (0,3,4,5,6) (0,1,4,7) (2,5,7) (3,5,6,7) (0,5) (0,1,3,5,6,7) {28,17,19,33,26,47,28,36}
63+
[.#.##.#.#] (0,3,4,5) (2,3,6,7,8) (0,2,3,4,5,7,8) (3,4,6) (0,1,3,4,5,6,7,8) (0,2,3,4,5,6,8) (1,3,6,8) {26,31,23,71,41,26,64,26,54}
64+
[.#..#.#] (0,1,3,5,6) (0,3,5,6) (4,6) (0,1,2,3,4,6) (1,2,5,6) (0,3,4,5) {225,21,10,225,30,221,223}
65+
[.#...#] (0,3,4) (0,1,2,3,4) (0,1,2,3) (0,2,4) (2,3,4) (3,5) (0,2,3,5) (0,1) {97,55,66,91,45,29}
66+
[#.......] (5,7) (2,4) (0,2,3,4,5,6) (0,1,2,3) (2,3,4,5,7) (0,1,2,3,5,6,7) (1,6) (0,1,2,4,6) {44,41,62,43,47,39,53,22}
67+
[.##...##] (0,1,3,4,7) (1,2,3,5) (0,1,3,7) (0,1,2,3,4,6) (1,2,6,7) (1,4,5,6) (0,1,2,5,6,7) {46,73,32,52,37,23,34,40}
68+
[...#.##] (1,2,4) (0,1,2,5) (0,3,4,6) (4,5) (0,1,4,6) {36,203,193,11,203,19,21}
69+
[##..#.] (0,1,2,4,5) (0,2,5) (0,1,4,5) (1,3,4,5) (0,1,4) (0,2,3,4) {155,56,125,123,160,55}
70+
[.###] (0,2,3) (2) (0,2) (0) (0,1) (1,2) {39,10,42,11}
71+
[.#..##] (1,2) (0,2,3,5) (0,5) (0,2,4) (0,1,2,3) {150,121,144,121,10,32}
72+
[.#..#] (1,3,4) (0,3,4) (1) (1,3) (0,2,4) (0,2,3) (1,2,3) {33,23,30,43,19}
73+
[.##.##...] (1,2,3,4,5,7,8) (0,1,3,5,7) (6) (0,1,4,7,8) (0,1,5,6) (1,7) (3,4,5,6) (0,1,2,3,4,6,7) {40,67,18,34,38,26,19,65,24}
74+
[..#.#.] (0,1,4,5) (3,4) (0,1,2,3,4) (2,3) {17,17,181,187,23,14}
75+
[.##..] (1,3) (0,1,3) (0,2,3) (3,4) (2,4) {22,25,4,43,14}
76+
[...#.#..##] (0,1,2,4,5,6,7,8) (0,2,4,6,7,8,9) (5,7) (1,5,6,7,8) (0,3,4,5,6,8,9) (0,3,5,6) (0,7,9) (0,1,2,3,4,5,6,9) (1) {203,54,35,160,164,186,190,53,159,168}
77+
[..##] (0,2) (2,3) (0,3) (1,2,3) (0,1) {27,10,197,193}
78+
[.##..##..#] (1,3,4,5,6) (0,6,9) (6) (0,1,3,5,6,8,9) (1,4,6,7) (0,1,2,3,4,6,8,9) (2,4) (1,5,8) (0,1,2,4,5,6,7,8) {57,78,43,37,62,63,90,24,59,39}
79+
[##.#.##] (0,1,2,4,6) (0,1,2,3,4) (1,2,3,5,6) (0,1) (0,1,5,6) (2,5,6) (2,3,5) (0,1,5) {56,75,46,39,24,53,37}
80+
[##.#....] (0,1,6) (1,2,4,5,6) (2,3,5,7) (0,3,4,5,6) (2,3,4,6) (0,1,3,4,6) (0,1,2,4,5,6) (0,3,5,7) (1,2,5) (0,1,2,3,5,6,7) {72,64,56,62,60,82,81,34}
81+
[..#...] (1,2,5) (1,3,4,5) (2,3,4) (2,5) (0,3) (2,4,5) (1,4) (0,3,5) {2,43,27,28,62,43}
82+
[.##...#.] (6) (0,7) (1,3,4,7) (4,6,7) (2,5) (0,1,2,4) (1,2) (3,4,5,6) {8,26,20,20,33,14,14,21}
83+
[#.#..] (0,2) (0,1,2,4) (0,1,2,3) {18,18,18,15,3}
84+
[..##.] (2,3,4) (0,2) (1,2) (0,3,4) (0,3) (0,2,3) {40,166,189,31,26}
85+
[..##.#.#] (0,7) (1,3,4,5) (0,1,3,4,5,7) (0,1,2,3,4,5,6) (0,3,5,6,7) (1,2,3,4,5,7) (1,4,5) (0,2) {28,57,14,54,57,60,4,36}
86+
[.#.#..] (2) (0,4,5) (0,1,2,3) (2,4,5) (3,4) {25,19,201,35,29,13}
87+
[##.#] (0,2,3) (0,2) (2) (1,3) (2,3) {30,9,53,39}
88+
[.##.##..] (0,1,3,5) (0,3,4,6) (0,1,3) (5,6,7) (0,1,3,4,7) (0,1,3,6,7) (2,3,4,5,7) (0,2,3,4,6,7) (0,2,5) (1,2,4,5,7) {233,54,194,237,219,50,212,221}
89+
[#...] (0) (0,2) (2,3) (0,1) {39,4,34,18}
90+
[#.#.#.#.] (3,4,5,6,7) (0,2,3,5,6,7) (0,1,3,4,5,6,7) (0,2,3,4,5) (0,1) (0,2,3,5,7) (0,1,2,3,5,6,7) (1,7) (1,4,6) {60,44,47,67,36,67,59,62}
91+
[###....] (1,2,3,6) (4,6) (0,4,6) (4,5) (1,2,3) (0,4,5,6) (0,1,2,4,5) {10,28,28,23,32,22,29}
92+
[#####.###] (0,2,5,7) (1,2,5,6,7,8) (1,2,3,4,5,7,8) (0,1,3,4,5,7,8) (0,1,3,4,6,7,8) (1,3,5,7) (0,1,2,4) (2) (0,1,4,8) (0,1,2,3,4,6,7,8) (0,2,5,8) {49,63,52,35,41,46,31,61,49}
93+
[.#.#] (1,3) (0,3) (0,1,2) (1,2) {117,130,112,23}
94+
[...##...] (3,4,5,6,7) (0,5) (1,2,3,5,7) (0,1,2,3,7) (1,3,6) (0,3,5) (0,1,2,3,5,6) {38,218,23,231,2,55,203,19}
95+
[....#...] (0,2,3,4,5,7) (0,1,2,3,4,7) (0,3,7) (2,5) (0,2,3,5,6) (1,3,4,5,6,7) (3,4,5,6) (2,4,7) (4,5) {22,19,18,53,42,50,36,41}
96+
[.#####..] (1,2,3,6,7) (0,3,5,6) (0,1,2,4,5,7) (1,2,3,4,5,7) (5,6) (4,7) {30,33,33,27,44,46,27,51}
97+
[.....##.#] (0,2,3,6,7,8) (1,3,5,6,7) (0,1,2,5,6,7) (0,1,2,3,4,5,6,7) (1,2,3,5,6,8) (0,3,4,5,6) (0,7) (0,1,2,4,5,7,8) (0,2,3,6,8) (5,6,8) {76,34,57,49,41,53,56,53,49}
98+
[#.###] (0,2,4) (1,2,4) (1,2,3,4) (0,3) {200,16,24,195,24}
99+
[##...#.] (0,2,3,4,6) (0,4,5,6) (0,1,4,5,6) (2,3) (1,2,3,4,5,6) {10,17,35,35,27,26,27}
100+
[#.##.#] (1,3) (0,1,4,5) (0,2,3,5) (1,5) (0,2,5) (5) (1,2,3) (1,2,4,5) {38,59,53,51,25,67}
101+
[###.##] (1,4) (0,2,3,4,5) (1,3) (0,3) (0,2) {211,12,195,202,194,184}
102+
[##...####] (1,7) (2,5,7,8) (5,6,7) (0,2,3,4,5,6,8) (0,1,2,3,4,5,7) (0,1,3,7) (0,1,4,5,6,8) (0,2,6) (0,1,2,5,8) {43,39,44,20,27,49,20,34,28}
103+
[...#.#.#.#] (1,4,5,8,9) (0,1,3,5,7) (0,1,2,3,4,5,6) (0,1,2,4,5,7,8,9) (4,6,7) (0,2) (1,3,4,5,6,8) (0,1,2,3,4,5) (1,2,4,6,8,9) (6,9) (0,2,3,5,6,7,8,9) (1,7) {62,83,81,43,70,61,53,51,56,53}
104+
[##....#..] (0,1,2,3,4,5,6,8) (0,1,6) (0,2,3,5,6,7) (1,2) (1,2,3,6,7) (0,1,2,3,5,7) (2,3,4,5) {37,56,85,68,21,51,39,47,1}
105+
[..#..#] (0,3,4,5) (2,5) (1,2,5) (1,2,3) {19,18,37,29,19,46}
106+
[#..######.] (0,3,8) (0,1,2) (2,3,5,6,8,9) (1,7,9) (0,5,8) (0,4,9) (0,1,4,6,8) (6,7,8) (1,2,5,9) (3,4,5,8,9) (0,3,6,7,8,9) (3) {40,42,36,48,28,57,41,21,74,50}
107+
[.#....] (0,2,3,5) (2,4) (1,2,3,4) (4) (0,2,3,4,5) (1,3,4,5) (2,3,4,5) {11,24,47,55,62,43}
108+
[.##..##] (0,3,6) (2,4,5,6) (0,1,2,3,4,6) (1,4,5) (0,2,3,6) (3,4) {176,6,172,191,26,11,181}
109+
[#.#..####] (0,1,2,3,4,5,6,8) (0,1,2,3,5,6,8) (0,4,5,6,7) (0,2,3,4,6) (0,3,5,6) (6,7) (0,2,5,6,7,8) (2,3,4,5,6,8) {76,23,51,67,54,66,94,27,34}
110+
[.##.##.] (1,2,3,6) (1,3,4,5,6) (1,2,4,5) (3) (0,5) (0,2) (0,3,4) (0,2,5) (4) {148,43,62,51,27,153,36}
111+
[#.##] (0,1,3) (1,2) (0,3) {175,36,20,175}
112+
[.###.#] (1,2,4,5) (4,5) (1,3) (0,1,4) (0,1,4,5) (0,4) {10,43,13,20,25,24}
113+
[..###.#] (1,2,4,5,6) (2,5) (1,2) (0,1,4) (3,4,5,6) (0,3,4,5) (0,2,4) (3) (6) {132,36,164,38,167,61,50}
114+
[#.#....#] (3,5) (0,1,2,3,4,5) (0,1,3,4,5,6) (0,2,3,4,7) (1,2,3,5,7) (2,6) (0,1,3,4,6,7) (6,7) (1,6,7) (2,3,4,7) {37,66,49,72,47,43,45,64}
115+
[.#...] (0,1,2,3) (1,2) (0,2,3,4) (0,1,3) {133,15,146,133,132}
116+
[..#..#....] (0,1,2,5,8,9) (1,4,5,6,7) (0,2,3,4,5,6,8,9) (0,1,3,5,6,8) (2,3,5) (0,1,3,4,5,7,8,9) (0,1,2,3,4,8) (0,1,2,4,7,9) (0,1,3,4,5,6,8,9) (0,1,5,7,8) (0,3,4,9) (1,6) (4,5,6,7) {86,99,36,84,72,95,65,44,71,58}
117+
[.##...#.#] (1,2,3,4,5,6,7) (5,8) (0,4,5,8) (0,4) (2,5,6,7) (2,7) (2,8) (0,1,4,6,8) (0,1,3,7) (2,5,6,7,8) {68,38,28,22,50,48,31,39,60}
118+
[#.#####] (2,3,4,6) (2,5) (1,3,4,5,6) (1,2,5,6) (0,5,6) (0,1,2,3,4,6) (1,2,3,5,6) (1,3,4,6) (0,2,3,4,5,6) {23,42,62,53,35,62,74}
119+
[..##..] (0,2,5) (2,3) (1,2) (0,4) (2,4,5) (0,3) {42,5,188,178,19,21}
120+
[#.#...##.] (0,1,2,3,5,6,7,8) (1,2,5,7,8) (0,1,2,4,5,6,7) (1,2,4,6) (1,2,7) (2,7,8) (0,1,5,7) (2,6,8) (4,6) (0,1,3,7,8) (0,2,6,8) {61,81,97,16,45,42,77,83,63}
121+
[##.##...#.] (0,2,3,4,7,8,9) (5,8) (1,2,5,7) (1,3,8) (0,1,2,3,4,5,7,8,9) (0,3,4,5,6,7,8,9) (4,5,6,8,9) (3,5,6,7) (1,9) (0,4) (1,3,4,6,7,9) (3,5,6,8,9) (1,2,3,5,8,9) {7,58,28,50,18,50,29,49,34,34}
122+
[####..#.] (0,1,3,4,5) (1,2,3,4,7) (1,2,3,5) (1,2,3,4,5) (0,2,3,4,5,6,7) (1,4,5,7) {17,45,35,46,50,42,6,20}
123+
[.#.#.#.] (2,3,4,5) (0,4) (1,2,4,6) (0,1,2,3,6) (1,2,3,4,6) (0,4,6) {12,37,53,36,59,16,38}
124+
[##...#####] (0,1,5,6) (1,4,5,6,7,8,9) (0,1,2,3,4,5,6,7) (0,3,6,8,9) (0,4,5,6,7,8,9) (1,3,4,6,7,8,9) (2,3,4,8,9) (3) (0,1,2,4,5,7,8,9) (0,1,2,3,4,5,6,9) (0,2,5,6,7,9) (2,3,4,5,7) {66,88,60,76,107,91,85,93,89,90}
125+
[##..] (0,3) (0) (1) (2) (1,2) {7,5,16,3}
126+
[#.##] (0,1) (0,3) (2) {28,15,3,13}
127+
[##..] (1,2,3) (2,3) (3) (0,2) (0,1) (1) {15,185,20,23}
128+
[##.#] (0,1,3) (0,2,3) {151,140,11,151}
129+
[#.#.] (1,2,3) (0,2) {4,20,24,20}
130+
[#.##..#] (1,2,4,5) (2,5,6) (3,6) (0,1,3,4) (0,1,2,5,6) (0,1,5,6) {26,34,199,19,14,204,209}
131+
[#..#] (1,2) (0,3) (1) {11,16,1,11}
132+
[...#...#..] (3,7) (0,1,4,8) (0,2,3,4,6,8) (0,1,2,3,4,6,7,9) (0,4,5,6) (0,1,2,3,6,7,8,9) (1,2,3,6,7,9) (1,5,6,8,9) {54,43,48,56,42,7,55,43,33,36}
133+
[..#..###..] (0,1,2,3,6,9) (1,2,3,4,6,7,8) (0,2,4,8) (0,2,4,5,6,8,9) (0,3,4,6) (0,2,3,4,5,6,8,9) (0,1,5,7,8) (2,3,7,8,9) {71,32,75,68,71,42,74,32,73,53}
134+
[#.###] (0,2,3,4) (0,2,4) (0,1,2,3) (1,3) {51,24,51,41,32}
135+
[#.#..#.##] (2,3,6) (3,4,5,6,7,8) (0,1,2,3,4,6,8) (0,1,2,3,4,5,6,8) (1,3) (1,4,5,6,8) (6,8) (0,1,3,4,6,7) (1,2,3,4,8) (4,6) {44,211,64,232,70,14,80,19,53}
136+
[.###.] (3) (1,4) (2,3) (0,2,3,4) (1,2,4) (0,2) (2,4) {19,122,57,47,151}
137+
[##.#.] (0,2,3) (0,2,3,4) (1,2,4) (0,1,4) (0) (3,4) {36,19,26,33,36}
138+
[#..#.#..] (0,1,5,6) (3,6) (0,1) (0,1,3,4,5,6) (6,7) (5,6,7) (2,5,6) (2,3,4) (0,3,5,6) {48,47,29,225,34,64,274,34}
139+
[#.....] (0,2,3,5) (0) (0,1,2,3) (3,4) (0,1,4) (0,1,2,3,5) (1,2,3,4) (3,5) {29,20,24,41,20,23}
140+
[####] (3) (2) (1,2,3) (0,2) (0) (1,2) {21,31,39,14}
141+
[.#####..#] (1,4) (2,7,8) (2,4,5,6,8) (0,1,2,3,4,5,8) (0,5,6) (1,6) (2,4,5,7,8) (0,2,3,4,5) (3) {33,36,49,19,49,57,47,11,48}
142+
[.#...#.] (2,4,6) (3,4,6) (0,1) (1,4) (0,2) (0,1,3,4,6) (0,5,6) {8,14,9,24,40,1,32}
143+
[###.##.###] (2,8) (0,1,2,3,5,6,7,8,9) (0,2,4,5,7,8) (4,8,9) (0,1,4,5,6,7,8,9) (0,2,9) (0,1,2,3,4,5,8,9) (0,1,3,5,6,7,8,9) (0,1,3,5,8,9) (0,2,3,7) (0,1,2,3,5,6,7,8) {115,77,80,81,36,90,53,80,104,77}
144+
[#.###] (1,3) (0,3,4) (0,1,2,3) (0,2,4) (0,2,3,4) (1) (0,3) {50,22,31,56,44}
145+
[.#.#] (1,2) (0,2,3) (2,3) {13,8,194,186}
146+
[.#.#......] (8) (0,4,8,9) (0,2,4,8,9) (1,2,4) (0,1,2,6,8) (5,8) (2,3,5,6,7,8,9) (0,2,3,4,5,6,7,8,9) (2,3,5,7,9) (2,4,6,8,9) (0,1) (4,6,7) {81,45,76,21,77,35,44,26,99,60}
147+
[.#..##] (3,5) (1,2,3,4) (0,1,2) (0,1,3,4,5) (1,2) (1,2,3,4,5) (0,2,3) {35,59,60,62,44,24}
148+
[###..#] (1,2,5) (3,5) (0,3,4) (0,1,2,5) {174,165,165,32,15,182}
149+
[.#.#] (1,2) (1,3) (0,1) (0,1,3) (0,3) {38,69,19,39}
150+
[..#..#] (1,2,3,4,5) (4) (0,2,4) (2,5) (0,2,3,4) (0,1,3,4) {27,2,29,17,38,4}
151+
[###.#.##.#] (1,6,8,9) (1,4,5,9) (1,2,3,5,6,8,9) (0,1,2,4,5,6) (0,1,3,4,5,6,7,8) (0,4) (0,2,3,4,5,7,8,9) (0,2,3,5,6,9) (0,2,3) (2,3,4,9) {61,69,176,183,198,81,62,23,46,185}
152+
[...##.#..#] (2,4,5,8,9) (0,2,3,4,5,6,7,8,9) (2,4,8) (7,8) (3,5,8) (0,4,6,8,9) (4,5,6,7,9) (1,2,3,4,5) (0,1,2,5,6,7,8,9) {32,10,38,29,53,38,35,19,71,35}
153+
[...##..] (0,2,4,5,6) (2,3,4,5,6) (1,2,3,4,6) (1,3,4,5,6) (0,1,2,3,6) {111,26,127,35,142,135,144}
154+
[...###.###] (0,1,2,3,6,7,8,9) (0,1,4,5,6,8) (1,2,3) (0,2,6,7) (1,4) (3,6) (1,2,3,6,7) (2,4) (4,5,6,8) (1,2,3,6,7,8,9) (0,2,3,4,6,7,9) {8,65,45,203,30,7,197,31,17,12}
155+
[...#.##] (3,6) (0,1,3,4) (0,2,3,4,5,6) (0,1,4,5) (3,5,6) (0,1,2) (0,1,2,4) {68,56,34,48,49,36,30}
156+
[.#.#..#] (1,4) (2,3,4) (5,6) (1,2,3,5) (0,1,2,3,4,6) (3,4,5) (3,5) (0,2,5,6) {13,25,49,39,23,41,23}
157+
[.#..] (0,1,2) (2,3) (0,2) (0,2,3) {46,7,57,30}
158+
[#####.#.] (0,3,4,5,7) (0,1,6) (0,1,3,5,6,7) (2,3,5) (2,3,4) (1,4,5,6,7) {36,28,24,40,33,30,28,21}
159+
[...#.##.#] (0,2,7,8) (1,4,6) (0,1,2,3,4,5,6) (7,8) (1,2,4) (0,6,7,8) (0,1,2,3,5,6,7) (3,7,8) (1,2,3,4,5,6,7) {44,70,68,55,64,38,64,75,51}
160+
[..#.#] (4) (0,3,4) (0,2,3,4) (0,1,2) (3) (1,2,3) (2,3,4) {24,17,48,51,53}
161+
[####....#.] (6,7) (0,2,3,4,5,6) (0,1,4,5,6,7,8) (1,9) (1,4,7,8) (1,6,8) (1,6) (2,3,4,7) (3,5,8) (0,8,9) (1,2,3,4,6,7,8,9) (4,7,8) (2,5,9) {35,53,31,28,29,41,61,24,48,42}
162+
[.##.#.###] (0,2,3,4) (3,4,6) (0,3,8) (0,1,5,6,7,8) (2,3) (0,1,2,4) (0,1,3,5,6,8) (0,2,4,5,6,8) (0,4,5,8) (1,3,4,5,8) {39,3,17,32,48,27,33,0,38}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package eu.sim642.adventofcode2025
2+
3+
import eu.sim642.adventofcodelib.graph.{BFS, GraphSearch, TargetNode, UnitNeighbors}
4+
5+
object Day10 {
6+
7+
type Lights = Vector[Boolean]
8+
type Buttons = Seq[Seq[Int]]
9+
type Joltages = Seq[Int]
10+
11+
case class Machine(lights: Lights, buttons: Buttons, joltages: Joltages)
12+
13+
def fewestPresses(machine: Machine): Int = {
14+
val graphSearch = new GraphSearch[Lights] with UnitNeighbors[Lights] with TargetNode[Lights] {
15+
override val startNode: Lights = machine.lights.map(_ => false)
16+
17+
override def unitNeighbors(lights: Lights): IterableOnce[Lights] =
18+
machine.buttons.map(_.foldLeft(lights)((acc, i) => acc.updated(i, !acc(i))))
19+
20+
override val targetNode: Lights = machine.lights
21+
}
22+
23+
BFS.search(graphSearch).target.get._2
24+
}
25+
26+
def sumFewestPresses(machines: Seq[Machine]): Int = machines.map(fewestPresses).sum
27+
28+
def parseMachine(s: String): Machine = s match {
29+
case s"[$lightsStr] $buttonsStr {$joltagesStr}" =>
30+
val lights = lightsStr.map(_ == '#').toVector
31+
val buttons = buttonsStr.split(" ").map(_.tail.init.split(",").map(_.toInt).toSeq).toSeq
32+
val joltages = joltagesStr.split(",").map(_.toInt).toSeq
33+
Machine(lights, buttons, joltages)
34+
}
35+
36+
def parseMachines(input: String): Seq[Machine] = input.linesIterator.map(parseMachine).toSeq
37+
38+
lazy val input: String = scala.io.Source.fromInputStream(getClass.getResourceAsStream("day10.txt")).mkString.trim
39+
40+
def main(args: Array[String]): Unit = {
41+
println(sumFewestPresses(parseMachines(input)))
42+
}
43+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package eu.sim642.adventofcode2025
2+
3+
import Day10._
4+
import org.scalatest.funsuite.AnyFunSuite
5+
6+
class Day10Test extends AnyFunSuite {
7+
8+
val exampleInput =
9+
"""[.##.] (3) (1,3) (2) (2,3) (0,2) (0,1) {3,5,4,7}
10+
|[...#.] (0,2,3,4) (2,3) (0,4) (0,1,2) (1,2,3,4) {7,5,12,7,2}
11+
|[.###.#] (0,1,2,3,4) (0,3,4) (0,1,2,4,5) (1,2) {10,11,11,5,10,5}""".stripMargin
12+
13+
test("Part 1 examples") {
14+
assert(sumFewestPresses(parseMachines(exampleInput)) == 7)
15+
}
16+
17+
test("Part 1 input answer") {
18+
assert(sumFewestPresses(parseMachines(input)) == 449)
19+
}
20+
}

0 commit comments

Comments
 (0)