2025 Day 10 Solved!
This commit is contained in:
3
.envrc
3
.envrc
@@ -5,3 +5,6 @@ export CURRDAY=`date +%d`
|
||||
export CURRMONTH=`date +%m`
|
||||
export CURRYEAR=`date +%Y`
|
||||
export TODAYDIR="$AOCROOT/$CURRYEAR/day$CURRDAY"
|
||||
|
||||
export CGO_CFLAGS="-I/usr/include/lpsolve"
|
||||
export CGO_LDFLAGS="-llpsolve55 -lm -ldl -lcolamd"
|
||||
|
||||
167
2025/day10/input
Normal file
167
2025/day10/input
Normal file
@@ -0,0 +1,167 @@
|
||||
[..##.#.] (0,4) (1,3,5) (0,6) (0,2,3,5) (2,5,6) (2,3,5) (0,1,2,4) (0,5) {67,29,30,40,18,54,21}
|
||||
[.######.#] (0,2,3,4,6,7) (1,4,6) (0,4,6) (1,3,4,5,8) (1,7,8) (1,2,3,4,5,6,8) (0,2,7,8) {19,48,35,34,54,29,42,18,42}
|
||||
[..####] (0,1,2,3,4) (0,1,3,4) (0,1,2) (0,1,3,5) (4) {38,38,12,26,22,9}
|
||||
[.#...#.#..] (3,5) (1,2,3,4,6,8,9) (0,4,8,9) (2,3,4,5,6,7,8,9) (6,8) (1,4,5,7,8) (1,2,5,9) (0,1,3,4,5,6,9) {5,22,17,25,34,32,38,24,45,22}
|
||||
[.###] (0,2) (0,1,3) (1,2) {13,8,5,8}
|
||||
[.#...###] (1,6) (0,2,5) (0,2,3,7) (0,3,5,6,7) (0,1,2,5) (0,1,2,3,4,5,6) (0,1,3,5,6) (0,1,4,5,6,7) (0,1,2,3,4,6) {92,78,57,69,39,70,83,26}
|
||||
[#####.###.] (0,1,3,4,5,7,8) (0,2,3,4,5,6,7,8) (0,1,3,4,6,7,8,9) (0,3,4,5,7,9) (0,3,5,6,7,8,9) (0,2,4,5,7,8) (0,1,2) (0,5,7,8) (0,5,6) (3,9) (2,5,6,8,9) (0,1,2,3,4,6,7,8) (1,3,4,5,6,8,9) {284,45,50,74,48,286,268,75,99,62}
|
||||
[###.###.#] (1,2,4,5,7,8) (1,4,8) (0,1,2,4,5,6,7) (5,7) (0,1,2,3,4,5,8) (3,6) (3,4,5,7,8) (0,2,3,4,6) (2,3,4,6,7) {28,21,52,45,56,26,42,37,17}
|
||||
[..####] (1,2,5) (1,3,4) (2,3,4) (0,3,4,5) (4) (0,2,5) (0,1,2,3,5) (0,2,3,4) {34,112,150,34,45,126}
|
||||
[..##..##] (3,5,7) (0,6) (2,3,5,6) (0,4,7) (0,1,3,4,5,7) (2,3,6,7) {36,15,11,34,16,33,31,25}
|
||||
[###..###.#] (0,1,2,3,4,5,6,9) (3,4,7) (0,3,4,7,9) (2,4,6,7,8) (6,9) (2,8) (0,5) (6,7) (0,1,2,3,4,5,6,7,9) (1,2,3,6,7,9) {18,25,58,28,27,15,68,52,33,39}
|
||||
[####] (1,2) (0,3) (0,1) {17,17,4,4}
|
||||
[##..] (0,1,3) (0,1) (0,1,2) (0,3) {54,43,19,23}
|
||||
[..##....] (7) (3,5,6) (0,1,2,3,4,6,7) (3,6,7) (2,5,7) (3,6) (0,1,4,5) (5,7) (0,1,2,3,4,7) {10,10,25,44,10,45,43,44}
|
||||
[..###.] (0,4,5) (0,1,2,4,5) (0,2,3,5) (2,3,4) {27,18,35,17,42,27}
|
||||
[..###.#] (2) (0,5) (0,1,2,3,4,6) (3,5) (2,4,5,6) (0,5,6) (2,3,4,6) (1,4,5) {31,13,28,21,24,31,42}
|
||||
[..#.#] (3) (0) (1,2) (4) (0,2) (1) (2,3,4) {14,17,17,1,12}
|
||||
[.####] (1,4) (1,2,3,4) (0,2,3,4) {18,31,31,31,49}
|
||||
[##....#.##] (3,5,7,8) (4,5,6,8,9) (0,1,3,5,7,8,9) (1,2,4,5,6,7,8,9) (2,3,4,9) (0,1,3,4,5,7,8,9) (2,4,8) (1,4,8) (0,1,2,3,4,5,7,9) (0,2,3,4,7) {55,62,64,72,95,93,38,90,85,78}
|
||||
[.##....] (1,2,4,5) (0,1,3,4) (2,3,4,5,6) (1,2,4,5,6) (1,2) (0,1,3,4,5,6) (0,2,3,5) (0,1,3,6) {61,83,62,79,66,59,56}
|
||||
[..##...] (0,2,3,4,6) (0,5) (1,2,5,6) (2,3) (3,6) {11,0,18,22,5,6,9}
|
||||
[..####.#..] (1,5,7) (5) (1,2,3,9) (1,2,3,4,6,7,8,9) (3,5,6) (4,6,7) (1,3,4,5,6) (0,2,4,7,8,9) (0,5,8,9) (0,4,5,6) (1,2,3,4,8,9) (1,3,4,5,6,7,8) {33,59,54,57,64,54,41,50,58,66}
|
||||
[.#####.] (0,1,2,3,6) (1,2,3,4) (2,3) (0,1,2,4,5) (3,6) (0,2,3,4,6) (3,4,6) {14,27,40,54,45,9,28}
|
||||
[.#.#] (0,2) (0,1) (0,1,2) (0,3) (3) {20,15,2,16}
|
||||
[.#...] (1,2,3,4) (2,3) (3,4) (0,3,4) (0,2) (1,4) {15,33,41,47,52}
|
||||
[##.#] (0,1,3) (0,1,2) {21,21,15,6}
|
||||
[.....##.] (2,4,5) (0,1,2,3,4,5,7) (1,2,3,5,7) (0,2,4,5,6,7) (3,7) (0,2,4) (1,3,6,7) (0,1,2,3,5,6) {203,205,214,205,204,204,38,205}
|
||||
[##.##....] (3,6,7,8) (0,1,2,3,5,6,7) (1,3,5) (0,2,4,6) (0,1,4,7,8) (6,7) (0,1,2,3,4,8) (1,2,3) (0,3,4,5,6) (1,2,3,4,5,6,8) {25,49,39,55,35,27,48,32,28}
|
||||
[.#..###] (0,1,2,5) (0,1,4) (0,2,3,5,6) (1,5) (0,1,3,5) (3,5) (1,2,4,5,6) (0,1,3) (4,6) {170,189,156,32,39,185,40}
|
||||
[##..##.##.] (1,3,5,6,7,8) (0,6,8) (2,6,7,9) (0,1,2) (0,1,3,5,6,9) (0,1,2,3,5,6,7,9) (1,4,7) (1,4,5,9) {40,35,27,28,7,30,52,35,18,36}
|
||||
[..#..#] (0,2,3,5) (0,1,3,5) (2,4) (0,3) (1,2,3,4,5) (1,3,5) {30,38,22,56,8,52}
|
||||
[##....] (0,1,2,3,5) (0,1,3,5) (0,1,2,4) (5) (2,3) (0,2,3,4) (0,1) {52,49,26,42,3,42}
|
||||
[##.#....##] (4,6,7) (3,5,6,7,8) (0,1,2,4,5,9) (6,7,9) (0,1,3,4,8) (2,3,4,5,6,8) (0,1,2,5,7,9) (0,1,2,3,4,6,8,9) (0,1,3,4,5,8,9) {46,46,41,45,50,32,36,21,45,38}
|
||||
[#....#.#.] (1,3,6,7) (1,2,3,4,7,8) (1,2,3,6,8) (5,7) (2,4,6,7) (3,5,6,8) (1,2,6,8) (0,4,5,6,7,8) (0,5,7,8) (0,1,3,5,8) {40,225,226,209,36,58,243,64,255}
|
||||
[...#] (0,1,2) (3) (0) (0,2) (1,3) (1,2) {41,45,42,37}
|
||||
[..###.###.] (2,8) (0,1,5,6,8,9) (0,1,3,4,6,7,8,9) (3,5,7,9) (0,4,5,9) (0,1,5,7,8) (0,1,5,9) (0,4,6,7,8) {201,48,18,15,168,180,30,40,67,176}
|
||||
[..#..#.##.] (0,2,6,7,8) (2,8,9) (0,2,3,4,7,8) (0,1,2,3,5,7,8) (1,5,6,7) (0) (1,2,3,4,6,8) (3,6) (2,7,8) (2,3,6,7,8) (1,2,4,8) (1,5,7,8,9) {54,35,73,44,36,16,47,60,82,17}
|
||||
[##.##.#] (0,2,4,5) (2,4,5,6) (0,1) (2,3,4,5,6) (0,1,3,4,6) (2,3,5) (1,2,3,5) (0,6) {39,33,222,198,58,222,52}
|
||||
[#.##..#.##] (0,3,8,9) (0,2,3,4,5,6,7,8,9) (5,7,9) (1,9) (3,7) (0,3,4,5,6,8,9) (2,3,4,5,6,7,9) (0,3,4,6) (3,5,6) (4,6,7,8,9) {57,12,26,95,54,71,74,52,47,80}
|
||||
[.#..#] (0,3,4) (1,2) (0,3) (1,3) (0,1,3,4) {27,32,14,28,22}
|
||||
[###.###] (0,1,5) (0,2,4,5) (1,3) (1,4,5,6) (0,1,2,3,5,6) (2,5,6) (1,2,4,5,6) {24,13,29,9,21,31,10}
|
||||
[###.###] (0,3,4) (5) (0,2,3,5) (6) (1,2,4,6) (2,4,5) (0,1) (0,1,2,4,5) (0,1,2,4,6) {17,26,28,5,25,23,16}
|
||||
[#...##] (1,2,3) (1,5) (0,5) (2,3,4,5) (0,2,4) {16,23,24,23,12,37}
|
||||
[#...] (0,1,3) (1,2) (1,3) {18,35,11,24}
|
||||
[.#.....] (0,6) (1,2,3,6) (0,2,3) (0,1,2,4,6) (0,1,3,4) (0,1,2,3) (3,4) (0,2,5) (0,2,3,4,6) {241,219,234,219,49,15,50}
|
||||
[##..##.#] (0,2,4,6,7) (2,7) (1,3,4,5) (0,4) (5) (2,5,6,7) (0,1,3,6,7) (0,1,2,4,6,7) {218,38,203,23,217,29,213,215}
|
||||
[###...#] (1,2,4,5) (0) (2,3,4,6) (3,6) (1,3) (1,2,3,4,6) (0,4,6) (1,4) (4,6) {36,53,32,33,61,18,38}
|
||||
[...#.] (0,1,4) (1,4) (1,2,3) (1,3,4) {15,206,20,24,186}
|
||||
[#..##...] (0,1,2,3,4,5,7) (1,2,3,7) (0,1,2,3,5) (1,2,3,5,6,7) (0,1,2,4,5,6) (0,1,2,5,6) {46,63,63,37,11,54,34,19}
|
||||
[#..#.] (0,2,4) (2,3,4) (0,1,2,4) (1) {13,12,160,147,160}
|
||||
[#..#] (0,1,3) (1) (1,2) (3) {0,27,9,12}
|
||||
[..#...#] (0,2,5,6) (5,6) (0,1,3,4,5) (5) (0,1,4) (2,3,5) (0,1,5) {45,34,15,9,14,64,20}
|
||||
[..###..] (0,1,3,4,5) (0,2,3,5,6) (0,2,6) (2,3,4,5) (0,1,2,4,5) (0,1,2,3,5) (2,3,4) {80,49,78,63,45,67,31}
|
||||
[###.##] (1,4) (0,1,2,4) (0,4,5) (0,1,2,3) (2,4) {24,27,36,8,45,7}
|
||||
[####.] (0,2,3) (2,3,4) (0,3) (1,2) (3,4) {23,1,15,35,12}
|
||||
[.#####.##] (0,6,8) (0,1,2,3,5,6,7) (0,2,6,8) (1,4) (0,3,6) (0,2,5,6,7,8) (0,1,3,8) (0,3,4,5,6,7,8) (1,3,5) {80,158,45,41,142,36,79,33,50}
|
||||
[.###] (0,2,3) (1,2,3) {9,9,18,18}
|
||||
[#.#####.#.] (1,2,6) (0,1,2,3,5,6,7,8) (0,1,2,4,5,6,7,8) (0,5,6,7,8) (1,2,4,6) (3,8) (2,4,6,7,8) (0,2,3,4,5,6,8,9) (0,2,4,8,9) (0,1,3,4,5,8,9) (0,1,2,4,6,7,8) (1,3,4,5,6,7,8,9) (4,9) {60,75,85,40,74,50,87,52,89,27}
|
||||
[.###] (0,1,3) (0,2) (0,2,3) (2) (2,3) {185,19,176,21}
|
||||
[##..###.#.] (7,8,9) (0,1,2,3,5,8,9) (5,7,8) (1,2,5,7,9) (0,6,8) (0,2,4,8) (2,4,9) (1,2,3,5,6,7,9) {30,38,61,20,23,40,19,47,52,76}
|
||||
[.###.#.] (0,1,2,3,4,5,6) (1,3,6) (1,2,5) (2,4,5,6) (0,1,2,3,6) (3,4,5) {19,48,40,47,21,37,37}
|
||||
[.#..#.#.] (2,7) (0,3,4) (3,6) (0,1,2,4,5,6,7) (0,1,2,3,4,5,7) (0,1,3,4) (0,1,5) {78,66,44,43,59,54,16,44}
|
||||
[...#.###] (4,5) (2,4) (1,2) (0,1,2,4,7) (2,3,6,7) (0,1) (0,1,3,4,6,7) (2,5,6,7) {212,212,61,190,229,22,206,226}
|
||||
[..#..#] (1,2,5) (2,5) (1,2,3,5) (0,2,4) {19,27,211,15,19,192}
|
||||
[#####] (0,3,4) (2) (1) (1,2,3) {12,20,18,16,12}
|
||||
[.#..#] (1,3,4) (1,3) (2,3,4) (0,1,3) (1,2,4) (3) (0,1) {103,129,6,145,24}
|
||||
[##..####] (3,4,5,6) (0,1,4,5,6,7) (0,2,4,6,7) (2,3,4,5,6) (0,2,3,7) (0,1,2,4,5) (3,6) {54,33,57,45,75,56,79,38}
|
||||
[#....#] (3,4) (0,5) (0,2) (0,1,3) (2,3,4,5) {35,3,15,12,9,17}
|
||||
[###.#.] (4) (1,2,3,4) (2,3) (0,5) (0,1,2,3,4) (0,1,2,5) {20,29,34,22,27,12}
|
||||
[....##.] (1,2,3,4) (0,1,3,6) (2,3,4,5,6) (1,3,4,6) (0,1,2,3,6) (2,4,5) {23,34,21,37,15,4,31}
|
||||
[.##.##.#.] (0,1,2,4,6,7,8) (0,1,3,4,6,7,8) (6) (0,2,3,4,7) (4,5,6,7) (0,2,5) (5,6) (0,1,4,5,6,7) {51,31,22,28,53,46,73,53,21}
|
||||
[..###...] (0,2,3,4,7) (0,1,5) (0,2,3,4,5,6) (0,2,4,6,7) (1,4,5,6,7) (0,7) (0,1,3,6,7) (1,7) (3) (0,1,3,4,5,6,7) {88,71,35,75,73,65,88,84}
|
||||
[#..#.##] (0,4) (2,5) (0,1,3,5,6) (0,3,5,6) (1,2,5) (0,4,6) {236,25,29,30,206,59,50}
|
||||
[#...###.#.] (0,2,3,4,7,9) (2) (3,8) (0,4,5,6,8) (3,4,6,7) (1,3,5,6,7,8,9) (1,2,3,4,6,7,8) (3,4,5,7,8,9) (0,1,2,4,8) (0,1,3,4,5,6,7,9) (0,4,5,7,8,9) (1,2,5,6,8) (0,1,2,3,4,5,6,9) {70,74,69,88,111,87,79,87,72,79}
|
||||
[.#..##....] (0,1,2,3,4,5,6,7) (2,5,7,9) (4,9) (0,2,4,5,6,7,8,9) (1,4,5) (0,1,2,4,6,7,8,9) (1,8) (0,1,2) (0,1,2,3,4,5,7,8) (0,1,2,3,6,7,8,9) (1,4,5,9) (0,1,2,5,7,9) (2,3,8,9) {92,103,110,52,73,69,66,97,86,74}
|
||||
[..##...#.] (2,5) (0,1,2,5,6,7,8) (1,3,5) (2,7,8) (3,4,7) (0,1,2,3,4,7,8) (0,1,3,4,5,7) (0,1,2,4,5,8) {34,35,46,30,36,45,11,44,29}
|
||||
[##.#..#] (0,5) (1,2,3,5,6) (1,3,5) (0,2,3,4,5) (0,2,3,4,5,6) {30,19,34,38,19,49,30}
|
||||
[.#..] (0,1) (0) (0,3) (1,3) (1,2) (2,3) {10,22,14,25}
|
||||
[.....#.#.#] (1,2,6,8,9) (2,4,7) (2,3,9) (0,1,3,4,5,6,7,8) (0,3,5) (0,3,5,6,7,8,9) (0,2,3,4,5,6,8,9) (0,1,2,5,6,8,9) (1,4,5,6,7,8,9) (1,2,3,4,5,6,7,9) (2,5,6,9) {52,33,71,67,43,77,72,34,56,85}
|
||||
[####.#.##] (0,1,2,3,6,7,8) (0,1,2,5,6,7,8) (4) (0,1,2,8) (2,3,4,5,7) (0,5,6) (4,6,8) (3,4,7) (1,7) {29,28,23,35,41,20,37,50,27}
|
||||
[.#.#] (2) (1,3) (0,3) {5,175,0,180}
|
||||
[.#...#.] (1,2,4,5,6) (0,1,3,5,6) (0,1,2,3,4) (1,2,4,6) (0,1,2) (0,1,2,3,5) (3,4,5) (0,3) {55,57,47,67,46,56,30}
|
||||
[##..] (1,2) (1,2,3) (0,2,3) {0,118,118,109}
|
||||
[....##..] (1,2,4,6,7) (0,1,3,4,7) (1,6) (1,3,6,7) (0,5) (2,4,6) (0,2,3,6,7) {16,40,20,29,25,7,50,32}
|
||||
[#....] (0,1,2,3) (0,2) (0,1,2,4) (1,2,4) (0,2,4) {33,193,207,1,204}
|
||||
[#..###.##] (0,1,2,3,4,5) (0,1,2,3,5,6) (4,7,8) (1,3,4,5,6,8) (4) (2,3) (1,2,5,8) (0,2,8) (0,2,3,4,5) (2,3,4,5,8) (0,1,2,3,6) {57,71,106,99,89,100,35,14,66}
|
||||
[##.####] (0,1,3,4,6) (2,3,4,5,6) (0,1,2,5,6) (0,3) (4,6) (2,5) (0,1,2,4) (3) (0,2,3,4,5,6) {46,28,34,53,49,30,50}
|
||||
[.##.#] (0,3) (1,3) (2,3,4) (0,2,4) {27,16,20,33,20}
|
||||
[.#.#] (1,2,3) (0,2) (1,3) (3) (1,2) {14,19,26,24}
|
||||
[#####] (1,3) (0,1,2) (0,1,2,3) (0,1) (0,3,4) (1,2,4) (0,2,3) {201,39,36,180,160}
|
||||
[###...#..] (1,2,3,4,5,7) (0,2,3,5,6,7,8) (0,1,2,5,6,8) (0,1,2,4,5,6,7,8) (2,3,7) (0,1,2,3,4,6,7) (2,8) (0,1,5,6,7) (0,3,6) (0,1,3,4,8) {97,229,228,211,197,220,94,227,51}
|
||||
[#..#.#.#.#] (3,4,5,9) (8) (6) (0,1,2,4,6,7,8) (1,3,4,5,6,7,8) (0,1,2,4,5,6,7,8) (1,2,3,5,6,8,9) (2,8) (0,3,5,6,7,9) {24,53,42,40,34,42,66,38,66,26}
|
||||
[#.#..] (0,3,4) (1,2,3) (0,1,3,4) (0,1,2) {26,40,35,31,11}
|
||||
[..##...#.] (2,4,5) (0,1,3,4,5,6,7) (1,3,4,5,6,7,8) (5,6,7) (2,4,5,6,7) (3) (1,2,4,5,7) (4,5,6,7) (0,6,7) {30,41,40,33,74,93,74,89,10}
|
||||
[....##.#] (0,1,2,3,4,6) (0,4,5,6,7) (0,1,2,3,5,7) (1,2,3,5,6) (5) (1,2,5,7) (0,1,2,3,5,6,7) (1,2,3,4,5,6,7) (4,5,6) {34,65,65,51,21,78,40,56}
|
||||
[.....#] (0,1,2,3) (2,3,4) (0,2,4,5) (0,1,3,5) (0,4) (4,5) (2,3) (2,3,4,5) {21,9,32,31,38,24}
|
||||
[.#.#..#] (2,3,4,5,6) (1,2,5,6) (0,2,3,4,6) (0,1,2,4) (0,2,4,6) (1,2,3,4,5) {29,36,50,7,36,21,28}
|
||||
[###..#] (2,5) (1,2,4,5) (2,4) (0,3,4,5) (0,1,2,4) (0,1,2,5) {9,29,42,0,34,28}
|
||||
[.#####.#.#] (5,6,7) (2,3,6,7) (0,2,3,4,6,7) (1,2,3,4,5,8,9) (0,1,2,3,6,7,9) (0,3,4,5,6,7,8,9) (8,9) (0,2,5,8,9) (0,1,2,3,5,7,8,9) {48,137,157,170,145,143,56,58,155,172}
|
||||
[..#..##.#.] (0,1,4,5,6,7,8,9) (0,1,2,3,4,6,8,9) (0,1,4,6,7,8) (0,1,9) (0,1,2,3,5,7,8,9) (0,2,3,4,5,6,7,8) (0,2,3,4,5,6,7,8,9) (0,2,6,7) (1) (3,7,8,9) (0,4,5,6,8,9) {88,68,38,58,63,61,63,79,100,82}
|
||||
[..#.#.#] (1,4) (2,4,5,6) (0,1,4,5,6) (0,1,3,6) (4,5,6) (0,1,2,3,5,6) (0,2,6) {41,32,34,24,27,34,60}
|
||||
[###.#.] (0,1,2,4) (0,1,2) (2,3,4,5) (2,3,4) (2,4) (1,2,3,5) {9,10,44,17,39,9}
|
||||
[.######..] (1,2,5,6) (4,6) (0,1,2,3,5,6,7) (2) (1,5) (2,5,6,8) (3,4,5) (2,3,4,5,6,7,8) (0,1,3,4,6) (0,1,2,3,4,6,7,8) (0,1,2,3,6,8) {47,67,85,66,62,77,98,53,52}
|
||||
[..#...#...] (1,2,3,4,5,7,8,9) (2,6) (1,2,3,5,6,7,8,9) (0,1,2,3,4,5,6,7,9) (2,5) (0,1,2,3,4,5,7,8,9) (5,6,7,9) (4,6,7) (0,1,2,3,4,5,6,9) (1,2,3,4,6,9) (0,1,3,6,7,8,9) (2,3,5,6) {28,63,74,70,47,77,87,68,28,82}
|
||||
[#.##.] (0,1,3,4) (3) (1,2) (2,3) (0,1,2,4) (4) {18,28,28,4,38}
|
||||
[.#...##] (3,4) (0,1,2,4,5) (4,5) (1,3) (0,2,5,6) (1,2,3,4,6) {16,37,24,199,205,27,12}
|
||||
[.###] (3) (1,2) (0,1,3) (0,2,3) {28,21,27,31}
|
||||
[#.##.] (0,1,3) (3,4) (0,1) (1,2,4) (0,2) (0,2,3) {32,29,31,28,26}
|
||||
[#..##..] (0,1,5,6) (1,3,4,5,6) (0,2,3,4,5,6) (1) (1,3,5) (1,3,4,5) (2,5,6) (0,2,3,4,5) (0,1,2,3,5,6) {29,55,41,62,44,90,48}
|
||||
[#.###.#] (0,1,3,4,5,6) (2,3,4,5) (1,4,5,6) (0,5,6) (2,3,4) {16,20,4,5,24,35,35}
|
||||
[.####...] (3,4,5,6) (1,6) (0,4,5,7) (0,1,2,3,7) (0,2,4,5,6,7) (3,6,7) (0,1) (0,1,2,3,4,5,6) (0,1,2,3,4) (2,3,4,5,6) {59,53,47,73,60,42,53,39}
|
||||
[##.######] (2,5) (4,7,8) (0,2,3,5,7) (0,5) (0,1,2,6,7) (0,4,5,7,8) (0,1,2,3,5,6,8) (2,8) (2,6) {166,22,73,23,15,170,30,38,42}
|
||||
[####] (1,3) (0,1,2,3) {10,25,10,25}
|
||||
[#####.#.#.] (3,9) (5,9) (0,3,4,8) (1,2,3,4,5,6,7,8) (4,6,7,8) (0,1,2,6,8) (0,4,5,8) (2,3,6,9) (1,2,5,6,7,8) (1,2,3,5,6,8) (0,2,3,5,6,7,8,9) (2,3) (0,2,6,7) {176,57,95,198,177,77,96,66,223,28}
|
||||
[..#.#.#] (0,2,4,5,6) (0,2,3,5,6) (0,1,5,6) (0,3,4,5,6) (0,1,2,3,5) {37,25,21,21,4,37,26}
|
||||
[##.#.#] (3) (0,4,5) (0,1,2,4,5) (0,1,4) (0,1,2,3) (0,1) (0,1,3,4) {194,54,11,40,168,145}
|
||||
[#..#.] (0,1,2,3) (1,2) (1,3,4) {14,29,18,25,11}
|
||||
[####] (3) (0,1) (1,3) (1) (0,2) (2,3) {20,14,181,184}
|
||||
[######] (0,1,2,5) (5) (1,3,4,5) (0,1,3,5) (1,3) (4) (0,1) {25,47,16,29,31,38}
|
||||
[#..#.#] (1,2) (1,2,4,5) (0,3,5) (0,4,5) (0,1,2,5) (1,3) {43,25,25,8,21,44}
|
||||
[#.#...##.] (2,3,7) (0,4,5,7) (3,4,5,7) (1,2,4,6,8) (2,5,6,7) (1,2,6,7,8) (1,4,5,6) {4,36,29,14,30,25,36,30,17}
|
||||
[..##] (1,3) (2,3) (0,2,3) (0,3) {7,12,12,28}
|
||||
[#####..#] (2,3,7) (0,1,2,3,4) (0,2,4) (0,1,2,4,5,6) (4,5) (2,4) (7) (1,5) (1,2,3,4,6) (2,3) {34,39,49,26,51,27,19,18}
|
||||
[.##..#..] (2,4,5,6) (0,3,5,6) (2,4,7) (2) (0,1,4,5,6,7) (0,1,2,3,4,5,6) (2,5,7) (0,5,6,7) (1,2) (1,2,3,5) {37,24,41,34,24,55,39,32}
|
||||
[.##.#] (1,2,4) (1,2) (0,2,3,4) {10,30,40,10,26}
|
||||
[###.##.] (0,5) (2,3,5,6) (3,4) (5) (2,4) (0,1,3) (0,1,2,4,6) (0,3) {48,18,176,179,39,176,159}
|
||||
[.###...] (0,1,5,6) (1,4) (1,2,3,4,6) (0,1,2,3,4,5) (2,3) {4,28,34,34,26,4,22}
|
||||
[#.#.#..#] (0,4,5,6,7) (0,1,3,4,5,7) (0,1,5,7) (0,3,4,5,7) (2,4,5,6) (6) (1,3,4) {35,28,12,39,55,47,22,35}
|
||||
[...##...] (0,1,2,6) (3,4) (2,5) (3,4,6) (0,2,6) (0,1,2,3,4,6,7) {20,15,40,30,30,20,37,3}
|
||||
[....##] (0,1,3,4) (0,2,4) (3,5) (0,3) (0,2,5) (1,2,4,5) (1,5) {41,45,29,33,40,42}
|
||||
[##..#..#.] (0,2,3,5,6,7,8) (0,2,3,4,5,6,7) (0,1,3,6,7,8) (1,2,7,8) (0,1,2,3,4,6,8) (0,2,3,5,7) (0,1,2,6,8) {64,50,74,50,31,27,58,43,60}
|
||||
[#.#.#] (2,3,4) (0,3) (1,4) {15,18,14,29,32}
|
||||
[....#] (2,4) (0,2,3) (0,1,2) (1,4) (0) (4) (1,3,4) {38,52,38,28,172}
|
||||
[##.#.###.] (1,2,3,4,5,6,7,8) (4,6,7,8) (0,1,7) (2,3) (0,1,3,4,5,8) (0,3,4,5,6,7,8) (0,1,4,6,8) {34,43,37,57,57,39,47,41,57}
|
||||
[.#..] (2,3) (0,1,3) (0,2) (1) (2) (1,3) {18,117,18,114}
|
||||
[.##...#.] (0,3,5,6,7) (5,6,7) (1,2,4,5,6) (0,3,4,5,7) (1,2,3,4,5) (0,4,5,6) (0,6,7) (1,3,4,6) (2,4,7) (0,2,3,4,6) {184,37,39,205,226,214,57,193}
|
||||
[#...] (3) (0,2,3) (0) (0,1,2) (0,3) {48,14,29,23}
|
||||
[##.#.#..] (0,1,2,4,6,7) (1,2,3,4,5,6,7) (0,1,2,4,5) (0) (0,1,3,5,7) (1,2,5,6,7) (0,1,2,3,4,5) (0,5,7) {63,51,33,26,25,57,12,38}
|
||||
[#....###.] (0,1,2,3,4,5,6) (3) (1,4,7) (0,2,4,5,6,7,8) (0,3,5,7,8) (3,4,7,8) (1,6) (2,4,5,6,7) (1,2,6) (0,2,3,4,5) (0,3,7) {168,48,74,169,100,177,70,181,133}
|
||||
[..#.#.] (1,3,4,5) (2,4) (1,2,4,5) (1,2,3,5) (0) (0,1,3,4,5) {21,58,45,47,56,58}
|
||||
[.###.#] (1,3,4,5) (0,1,2,4,5) (0,4) (2,4) {28,12,151,0,167,12}
|
||||
[#.##.] (0,2,3,4) (2) (2,4) (1,2,3) (1) {6,142,155,130,21}
|
||||
[..###.#] (2,3,4,5) (1,3,5) (0,1,2,4,5) (2,3) (0,4,5,6) (1,3,5,6) {19,23,39,54,37,56,34}
|
||||
[#.##.#] (1) (0,1,5) (3,5) (4) (0,1,2,4) (0) (1,3,4,5) (0,1,3,4,5) {14,23,8,18,26,18}
|
||||
[....#.####] (0,1,4,5,8,9) (0,4,5,7,8) (0,1,2,5,6,8) (3,4) (2,3,8) (2,3,4,5) (0,1,2,5,8,9) (3,5,6,8,9) (2,7) (0,1,2,4,5,6,8,9) (1,2,3,4,5,6,8,9) {50,58,95,206,63,226,199,31,242,208}
|
||||
[###.#] (1,4) (0,2,4) (0,2,3) (0,2) (2,3,4) (0,1,2) {59,20,75,34,45}
|
||||
[..##.##..] (0,2,3,4,5,7,8) (2,4,5,6) (3,7) (3,5,6,8) (1,2,3,4,6,7) (0,2,4,5,6,8) (0,5) (1,3,6,7,8) (0,1,2,6,7,8) (0,2,3,5,6,7) (0,2,5,6,7) {79,42,86,61,40,83,104,85,41}
|
||||
[#..##.] (0,3,4,5) (1,2,3,5) (0,2,3,4) (2,3,4) (1,2,4) (0,1,5) (2,3,4,5) (0,1,3,4) {37,54,53,55,61,57}
|
||||
[##..] (0,3) (0,2) (0,1) (0,2,3) {182,134,28,36}
|
||||
[.#.#.##.] (0,2,3,5,6) (0,1,4,5,7) (0,1,2,6,7) (3,5,7) (6,7) (0,2,3,4,6,7) (0,1,2,5,6,7) (0,1,2,3,5,7) (0,1,4,6) {66,43,52,40,20,52,77,69}
|
||||
[###.] (1,3) (0,1,2) {11,13,11,2}
|
||||
[...#.#.##] (1,2,3,4,8) (0,4,7) (0,1,5,7,8) (0,1,2,3,4,7) (0,1,2,3,4,7,8) (0,1,4,5,6,8) (1,2,6,7,8) (0,2,3,4,5,6,8) (0,1,6,7,8) {71,74,54,47,67,16,36,67,64}
|
||||
[##.##...#] (1,2,6,8) (2,3,4,5,7,8) (2,5,7) (0,6) (0,1,4,7,8) (0,1,2,4,7,8) (1,6) (2,3,4,5,7) (2,3,7) (0,2,3,6,8) {52,46,77,52,53,40,50,79,61}
|
||||
[.#.##....#] (1,2,4,6,7) (0,2,3,4,5,6,8,9) (2,3,5,6,9) (0,2,3,4,5,7,8) (4,5,7,8,9) (5,8,9) (0,1,2,4,5,7,8,9) (1,3,4,5,6,7) (0,1,2,8,9) {27,49,58,37,55,60,51,49,39,52}
|
||||
[...#..] (3,4) (0,2,5) (0,3) (1,3,4) (1,3,4,5) (1,2,4,5) (0,2,3,5) (1,2,3) {14,43,26,51,52,40}
|
||||
[##.###.##] (0,1,5) (0,3,7) (6,7) (0,1,3,5,6,7,8) (1,5) (3,5,6,7,8) (0,1,2,3,5) (1,3,4,5,6,7,8) (2,5) (0,1,3,4,5,6,7,8) {51,52,33,65,32,71,38,54,34}
|
||||
[#.#..####] (1,2,4,5,7) (6,7) (0,1,7,8) (0,4,6,7) (1,2,6,7) (0,3,4,5,6,7) (0,1,5) (1,2,3,4,5,6,7) {29,53,32,23,29,35,52,69,13}
|
||||
[.##.###...] (0,1,2,4,5,6,8,9) (0,5,8) (1,4,5,6) (3,6,7) (1,2,4,5,6,9) (1,6,9) (3,4,5,8) (0,1,2,4,7) (3,4,5,7,8,9) (0,1,2,3,6,7,9) {28,61,30,141,176,170,60,38,146,49}
|
||||
[...##] (2,4) (4) (1,2,4) (0,3) (0,1,4) (0,1,3) {42,35,29,33,53}
|
||||
[.##....#] (0,1,2,4,6) (0,3,4,5,7) (0,1,3,4,5,7) (1,2,3,5,6,7) (0,1,2,3,6,7) (0,1,2,3,4,5) {43,37,36,37,40,34,25,26}
|
||||
[####..] (1,3,4,5) (1,4,5) (0,2,3,4,5) (0,2,4,5) {18,8,18,4,26,26}
|
||||
[#######.] (0,1,2,3,4,6,7) (0,1,3,4) (2,3,4,6,7) (1,5) (1,3) (0,1,3,5,6) (3,6,7) {22,52,12,64,17,35,48,32}
|
||||
[##..#.#...] (1,2,4,6,7,8) (0,2,4,5,7,8,9) (5) (0,1,3,4,5,6,7,9) (0,4,5,9) (0,1,2,5,9) (0,1,3,5,6,7,9) (0,1,3,4,6) (3,4) (3,4,6,7,8,9) (5,9) {91,72,33,60,79,98,66,63,27,84}
|
||||
[##..#...#] (0,1,4,8) (1,2,5,6,8) (1,4,5,6,8) (0,1,2,3,5,7) (0,1,3,4,5,6) (0,2,3,4,6,7,8) (0,1,2,4,6,7,8) (0,2,3,4,5,6,8) {148,167,153,129,44,150,52,142,50}
|
||||
[###.#.] (2,3,4) (1) (0,1,4) (1,2) (0,1,5) (1,3,4) (2) (0,1,2,3,5) {9,45,41,28,23,9}
|
||||
[#...#] (0,1,4) (2,3) (0,1,2,3) (2,3,4) (1,2,3) (1,3) (3,4) {30,43,51,69,40}
|
||||
[###.....##] (0,1,2,3,4,6,8) (0,1,6,9) (0,2,3,4,5,6,7,8) (1,2,3,4,5,8) (0,6,7) (0,1,4,5,7,9) (2,3,4,6,8,9) (0,5,8) (0,3) (3,6,7,8,9) (2) (2,3,4,6,7,9) {55,42,71,79,70,41,60,45,58,53}
|
||||
250
2025/day10/main.go
Normal file
250
2025/day10/main.go
Normal file
@@ -0,0 +1,250 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/draffensperger/golp"
|
||||
|
||||
h "git.bullercodeworks.com/brian/adventofcode/helpers"
|
||||
)
|
||||
|
||||
func main() {
|
||||
inp := h.StdinToStringSlice()
|
||||
part1(inp)
|
||||
fmt.Println()
|
||||
part2(inp)
|
||||
}
|
||||
|
||||
func part1(inp []string) {
|
||||
machines := parseInput(inp)
|
||||
var ret int
|
||||
for _, m := range machines {
|
||||
r := m.Start()
|
||||
ret += r
|
||||
}
|
||||
|
||||
fmt.Println("# Part 1")
|
||||
fmt.Println(ret)
|
||||
}
|
||||
|
||||
func part2(inp []string) {
|
||||
machines := parseInput(inp)
|
||||
var ret int
|
||||
var wg sync.WaitGroup
|
||||
for _, m := range machines {
|
||||
wg.Go(func() {
|
||||
sol := m.SolveJoltage()
|
||||
ret += sol
|
||||
})
|
||||
}
|
||||
wg.Wait()
|
||||
fmt.Println("# Part 2")
|
||||
fmt.Println(ret)
|
||||
}
|
||||
|
||||
func parseInput(inp []string) []*Machine {
|
||||
var ret []*Machine
|
||||
for i := range inp {
|
||||
ret = append(ret, NewMachine(i, inp[i]))
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
type Machine struct {
|
||||
id int
|
||||
numLights int
|
||||
lights int
|
||||
wLights int
|
||||
buttons [][]int
|
||||
joltages []int
|
||||
jCounters []int
|
||||
}
|
||||
|
||||
func NewMachine(id int, inp string) *Machine {
|
||||
ret := Machine{id: id}
|
||||
pts := strings.Fields(inp)
|
||||
for _, p := range pts {
|
||||
in := p[1 : len(p)-1]
|
||||
switch p[0] {
|
||||
case '[':
|
||||
var l []int
|
||||
for i := range in {
|
||||
if in[i] == '#' {
|
||||
l = append(l, i)
|
||||
}
|
||||
}
|
||||
ret.wLights = intsToBitmask(l)
|
||||
ret.numLights = len(in)
|
||||
case '(':
|
||||
wP := strings.Split(in, ",")
|
||||
var w []int
|
||||
for i := range wP {
|
||||
w = append(w, h.Atoi(wP[i]))
|
||||
}
|
||||
ret.buttons = append(ret.buttons, w)
|
||||
case '{':
|
||||
wJ := strings.Split(in, ",")
|
||||
for i := range wJ {
|
||||
ret.joltages = append(ret.joltages, h.Atoi(wJ[i]))
|
||||
ret.jCounters = append(ret.jCounters, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
return &ret
|
||||
}
|
||||
|
||||
// Start presses buttons until the machine is running
|
||||
func (m *Machine) Start() int {
|
||||
bMasks := []int{}
|
||||
for _, b := range m.buttons {
|
||||
bMasks = append(bMasks, intsToBitmask(b))
|
||||
}
|
||||
// Start at the end
|
||||
endMask := 0
|
||||
current := map[int]bool{m.wLights: true}
|
||||
var ret int
|
||||
for p := 1; p <= 1000; p++ {
|
||||
nextSet := make(map[int]bool)
|
||||
for c := range current {
|
||||
for _, b := range bMasks {
|
||||
nextSet[c^b] = true
|
||||
}
|
||||
}
|
||||
current = nextSet
|
||||
if _, exists := current[endMask]; exists {
|
||||
return p
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (m *Machine) SolveJoltage() int {
|
||||
if slices.Equal(m.jCounters, m.joltages) {
|
||||
return 0
|
||||
}
|
||||
|
||||
nB := len(m.buttons)
|
||||
nJ := len(m.joltages)
|
||||
|
||||
lp := golp.NewLP(0, nB)
|
||||
lp.SetVerboseLevel(golp.NEUTRAL)
|
||||
|
||||
objCoeffs := make([]float64, nB)
|
||||
for i := range nB {
|
||||
objCoeffs[i] = 1.0
|
||||
}
|
||||
lp.SetObjFn(objCoeffs)
|
||||
|
||||
for i := range nB {
|
||||
lp.SetInt(i, true)
|
||||
lp.SetBounds(i, 0.0, float64(1000))
|
||||
}
|
||||
for i := 0; i < nJ; i++ {
|
||||
var entries []golp.Entry
|
||||
for j, btn := range m.buttons {
|
||||
if slices.Contains(btn, i) {
|
||||
entries = append(entries, golp.Entry{Col: j, Val: 1.0})
|
||||
}
|
||||
}
|
||||
targetValue := float64(m.joltages[i])
|
||||
if err := lp.AddConstraintSparse(entries, golp.EQ, targetValue); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
status := lp.Solve()
|
||||
if status != golp.OPTIMAL {
|
||||
return 0
|
||||
}
|
||||
|
||||
solution := lp.Variables()
|
||||
totalPresses := 0
|
||||
for _, val := range solution {
|
||||
totalPresses += int(val + 0.5)
|
||||
}
|
||||
return totalPresses
|
||||
}
|
||||
|
||||
func (m *Machine) Reset() { m.lights = 0 }
|
||||
|
||||
func (m Machine) String() string {
|
||||
l := bitmaskToBytes(m.lights, m.numLights)
|
||||
wl := bitmaskToBytes(m.wLights, m.numLights)
|
||||
return fmt.Sprintf("[%s] -> [%s] %d", string(l), string(wl), m.wLights)
|
||||
}
|
||||
|
||||
func intsToBitmask(i []int) int {
|
||||
mask := 0
|
||||
for _, v := range i {
|
||||
mask |= 1 << v
|
||||
}
|
||||
return mask
|
||||
}
|
||||
func bitmaskToInts(in int, length int) []int {
|
||||
var ret []int
|
||||
for i := 0; i < length; i++ {
|
||||
if in&1 == 1 {
|
||||
ret = append(ret, i)
|
||||
}
|
||||
in = in >> 1
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func bitmaskToBytes(in int, length int) []byte {
|
||||
var ret []byte
|
||||
for i := 1; i <= length; i++ {
|
||||
if in&1 == 1 {
|
||||
ret = append(ret, '#')
|
||||
} else {
|
||||
ret = append(ret, '.')
|
||||
}
|
||||
in = in >> 1
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func elim(mtx [][]int) ([]int, [][]int) {
|
||||
m := len(mtx)
|
||||
if m == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
n := len(mtx[0]) - 1
|
||||
pivCols := []int{}
|
||||
cRow := 0
|
||||
mat := make([][]int, m)
|
||||
for i := range mtx {
|
||||
mat[i] = make([]int, n+1)
|
||||
copy(mat[i], mtx[i])
|
||||
}
|
||||
for col := 0; col < n && cRow < m; col++ {
|
||||
pivRow := -1
|
||||
for row := cRow; row < m; row++ {
|
||||
if mat[row][col] != 0 {
|
||||
pivRow = row
|
||||
break
|
||||
}
|
||||
}
|
||||
if pivRow == -1 {
|
||||
continue
|
||||
}
|
||||
|
||||
mat[cRow], mat[pivRow] = mat[pivRow], mat[cRow]
|
||||
pivCols = append(pivCols, col)
|
||||
|
||||
for row := cRow + 1; row < m; row++ {
|
||||
if mat[row][col] != 0 {
|
||||
factor := mat[row][col]
|
||||
pivVal := mat[cRow][col]
|
||||
for j := col; j <= n; j++ {
|
||||
mat[row][j] = mat[row][j]*pivVal - mat[cRow][j]*factor
|
||||
}
|
||||
}
|
||||
}
|
||||
cRow++
|
||||
}
|
||||
return pivCols, mat
|
||||
}
|
||||
185
2025/day10/problem
Normal file
185
2025/day10/problem
Normal file
@@ -0,0 +1,185 @@
|
||||
Advent of Code
|
||||
br0xen [7](AoC++) 20*
|
||||
|
||||
--- Day 10: Factory ---
|
||||
|
||||
Just across the hall, you find a large factory. Fortunately, the Elves
|
||||
here have plenty of time to decorate. Unfortunately, it's because the
|
||||
factory machines are all offline, and none of the Elves can figure out the
|
||||
initialization procedure.
|
||||
|
||||
The Elves do have the manual for the machines, but the section detailing
|
||||
the initialization procedure was eaten by a [16]Shiba Inu. All that
|
||||
remains of the manual are some indicator light diagrams, button wiring
|
||||
schematics, and [17]joltage requirements for each machine.
|
||||
|
||||
For example:
|
||||
|
||||
[.##.] (3) (1,3) (2) (2,3) (0,2) (0,1) {3,5,4,7}
|
||||
[...#.] (0,2,3,4) (2,3) (0,4) (0,1,2) (1,2,3,4) {7,5,12,7,2}
|
||||
[.###.#] (0,1,2,3,4) (0,3,4) (0,1,2,4,5) (1,2) {10,11,11,5,10,5}
|
||||
|
||||
The manual describes one machine per line. Each line contains a single
|
||||
indicator light diagram in [square brackets], one or more button wiring
|
||||
schematics in (parentheses), and joltage requirements in {curly braces}.
|
||||
|
||||
To start a machine, its indicator lights must match those shown in the
|
||||
diagram, where . means off and # means on. The machine has the number of
|
||||
indicator lights shown, but its indicator lights are all initially off.
|
||||
|
||||
So, an indicator light diagram like [.##.] means that the machine has four
|
||||
indicator lights which are initially off and that the goal is to
|
||||
simultaneously configure the first light to be off, the second light to be
|
||||
on, the third to be on, and the fourth to be off.
|
||||
|
||||
You can toggle the state of indicator lights by pushing any of the listed
|
||||
buttons. Each button lists which indicator lights it toggles, where 0
|
||||
means the first light, 1 means the second light, and so on. When you push
|
||||
a button, each listed indicator light either turns on (if it was off) or
|
||||
turns off (if it was on). You have to push each button an integer number
|
||||
of times; there's no such thing as "0.5 presses" (nor can you push a
|
||||
button a negative number of times).
|
||||
|
||||
So, a button wiring schematic like (0,3,4) means that each time you push
|
||||
that button, the first, fourth, and fifth indicator lights would all
|
||||
toggle between on and off. If the indicator lights were [#.....], pushing
|
||||
the button would change them to be [...##.] instead.
|
||||
|
||||
Because none of the machines are running, the joltage requirements are
|
||||
irrelevant and can be safely ignored.
|
||||
|
||||
You can push each button as many times as you like. However, to save on
|
||||
time, you will need to determine the fewest total presses required to
|
||||
correctly configure all indicator lights for all machines in your list.
|
||||
|
||||
There are a few ways to correctly configure the first machine:
|
||||
|
||||
[.##.] (3) (1,3) (2) (2,3) (0,2) (0,1) {3,5,4,7}
|
||||
|
||||
• You could press the first three buttons once each, a total of 3 button
|
||||
presses.
|
||||
• You could press (1,3) once, (2,3) once, and (0,1) twice, a total of 4
|
||||
button presses.
|
||||
• You could press all of the buttons except (1,3) once each, a total of
|
||||
5 button presses.
|
||||
|
||||
However, the fewest button presses required is 2. One way to do this is by
|
||||
pressing the last two buttons ((0,2) and (0,1)) once each.
|
||||
|
||||
The second machine can be configured with as few as 3 button presses:
|
||||
|
||||
[...#.] (0,2,3,4) (2,3) (0,4) (0,1,2) (1,2,3,4) {7,5,12,7,2}
|
||||
|
||||
One way to achieve this is by pressing the last three buttons ((0,4),
|
||||
(0,1,2), and (1,2,3,4)) once each.
|
||||
|
||||
The third machine has a total of six indicator lights that need to be
|
||||
configured correctly:
|
||||
|
||||
[.###.#] (0,1,2,3,4) (0,3,4) (0,1,2,4,5) (1,2) {10,11,11,5,10,5}
|
||||
|
||||
The fewest presses required to correctly configure it is 2; one way to do
|
||||
this is by pressing buttons (0,3,4) and (0,1,2,4,5) once each.
|
||||
|
||||
So, the fewest button presses required to correctly configure the
|
||||
indicator lights on all of the machines is 2 + 3 + 2 = 7.
|
||||
|
||||
Analyze each machine's indicator light diagram and button wiring
|
||||
schematics. What is the fewest button presses required to correctly
|
||||
configure the indicator lights on all of the machines?
|
||||
|
||||
Your puzzle answer was 455.
|
||||
|
||||
--- Part Two ---
|
||||
|
||||
All of the machines are starting to come online! Now, it's time to worry
|
||||
about the joltage requirements.
|
||||
|
||||
Each machine needs to be configured to exactly the specified joltage
|
||||
levels to function properly. Below the buttons on each machine is a big
|
||||
lever that you can use to switch the buttons from configuring the
|
||||
indicator lights to increasing the joltage levels. (Ignore the indicator
|
||||
light diagrams.)
|
||||
|
||||
The machines each have a set of numeric counters tracking its joltage
|
||||
levels, one counter per joltage requirement. The counters are all
|
||||
initially set to zero.
|
||||
|
||||
So, joltage requirements like {3,5,4,7} mean that the machine has four
|
||||
counters which are initially 0 and that the goal is to simultaneously
|
||||
configure the first counter to be 3, the second counter to be 5, the third
|
||||
to be 4, and the fourth to be 7.
|
||||
|
||||
The button wiring schematics are still relevant: in this new joltage
|
||||
configuration mode, each button now indicates which counters it affects,
|
||||
where 0 means the first counter, 1 means the second counter, and so on.
|
||||
When you push a button, each listed counter is increased by 1.
|
||||
|
||||
So, a button wiring schematic like (1,3) means that each time you push
|
||||
that button, the second and fourth counters would each increase by 1. If
|
||||
the current joltage levels were {0,1,2,3}, pushing the button would change
|
||||
them to be {0,2,2,4}.
|
||||
|
||||
You can push each button as many times as you like. However, your finger
|
||||
is getting sore from all the button pushing, and so you will need to
|
||||
determine the fewest total presses required to correctly configure each
|
||||
machine's joltage level counters to match the specified joltage
|
||||
requirements.
|
||||
|
||||
Consider again the example from before:
|
||||
|
||||
[.##.] (3) (1,3) (2) (2,3) (0,2) (0,1) {3,5,4,7}
|
||||
[...#.] (0,2,3,4) (2,3) (0,4) (0,1,2) (1,2,3,4) {7,5,12,7,2}
|
||||
[.###.#] (0,1,2,3,4) (0,3,4) (0,1,2,4,5) (1,2) {10,11,11,5,10,5}
|
||||
|
||||
Configuring the first machine's counters requires a minimum of 10 button
|
||||
presses. One way to do this is by pressing (3) once, (1,3) three times,
|
||||
(2,3) three times, (0,2) once, and (0,1) twice.
|
||||
|
||||
Configuring the second machine's counters requires a minimum of 12 button
|
||||
presses. One way to do this is by pressing (0,2,3,4) twice, (2,3) five
|
||||
times, and (0,1,2) five times.
|
||||
|
||||
Configuring the third machine's counters requires a minimum of 11 button
|
||||
presses. One way to do this is by pressing (0,1,2,3,4) five times,
|
||||
(0,1,2,4,5) five times, and (1,2) once.
|
||||
|
||||
So, the fewest button presses required to correctly configure the joltage
|
||||
level counters on all of the machines is 10 + 12 + 11 = 33.
|
||||
|
||||
Analyze each machine's joltage requirements and button wiring schematics.
|
||||
What is the fewest button presses required to correctly configure the
|
||||
joltage level counters on all of the machines?
|
||||
|
||||
Your puzzle answer was 16978.
|
||||
|
||||
Both parts of this puzzle are complete! They provide two gold stars: **
|
||||
|
||||
At this point, you should [18]return to your Advent calendar and try
|
||||
another puzzle.
|
||||
|
||||
If you still want to see it, you can [19]get your puzzle input.
|
||||
|
||||
References
|
||||
|
||||
Visible links
|
||||
1. https://adventofcode.com/
|
||||
2. https://adventofcode.com/2025/about
|
||||
3. https://adventofcode.com/2025/events
|
||||
4. https://adventofcode.com/2025/shop
|
||||
5. https://adventofcode.com/2025/settings
|
||||
6. https://adventofcode.com/2025/auth/logout
|
||||
7. Advent of Code Supporter
|
||||
https://adventofcode.com/2025/support
|
||||
8. https://adventofcode.com/2025
|
||||
9. https://adventofcode.com/2025
|
||||
10. https://adventofcode.com/2025/support
|
||||
11. https://adventofcode.com/2025/sponsors
|
||||
12. https://adventofcode.com/2025/leaderboard/private
|
||||
13. https://adventofcode.com/2025/stats
|
||||
14. https://adventofcode.com/2025/sponsors
|
||||
15. https://adventofcode.com/2025/sponsors/redirect?url=https%3A%2F%2Fcoderabbit%2Elink%2Fadventofcode
|
||||
16. https://en.wikipedia.org/wiki/Shiba_Inu
|
||||
17. https://adventofcode.com/2025/day/3
|
||||
18. https://adventofcode.com/2025
|
||||
19. https://adventofcode.com/2025/day/10/input
|
||||
3
2025/day10/testinput
Normal file
3
2025/day10/testinput
Normal file
@@ -0,0 +1,3 @@
|
||||
[.##.] (3) (1,3) (2) (2,3) (0,2) (0,1) {3,5,4,7}
|
||||
[...#.] (0,2,3,4) (2,3) (0,4) (0,1,2) (1,2,3,4) {7,5,12,7,2}
|
||||
[.###.#] (0,1,2,3,4) (0,3,4) (0,1,2,4,5) (1,2) {10,11,11,5,10,5}
|
||||
1
go.mod
1
go.mod
@@ -5,6 +5,7 @@ go 1.25.1
|
||||
require (
|
||||
github.com/br0xen/termbox-screen v0.0.0-20190712162752-c91f70ac38c6
|
||||
github.com/br0xen/termbox-util v0.0.0-20190325151025-c168c0df31ca
|
||||
github.com/draffensperger/golp v0.0.0-20250721104811-2d405f0b4e68
|
||||
github.com/fatih/color v1.7.0
|
||||
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7
|
||||
github.com/go-gl/glfw v0.0.0-20191125211704-12ad95a8df72
|
||||
|
||||
10
go.sum
10
go.sum
@@ -2,6 +2,10 @@ github.com/br0xen/termbox-screen v0.0.0-20190712162752-c91f70ac38c6 h1:QaQWdi0Kg
|
||||
github.com/br0xen/termbox-screen v0.0.0-20190712162752-c91f70ac38c6/go.mod h1:g8Iv1LnV2Dg45Bg5uCATrYi5Y57mXWsqlPnfU2BhD5I=
|
||||
github.com/br0xen/termbox-util v0.0.0-20190325151025-c168c0df31ca h1:UMJCb+zIdrTX68nP5byq1xjW72UIqMBNxcYPlPFhnOs=
|
||||
github.com/br0xen/termbox-util v0.0.0-20190325151025-c168c0df31ca/go.mod h1:x9wJlgOj74OFTOBwXOuO8pBguW37EgYNx51Dbjkfzo4=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/draffensperger/golp v0.0.0-20250721104811-2d405f0b4e68 h1:Zt1kA9y7DnXA5ACqWhHFD7yVXag6/uNsikEyR+4l+40=
|
||||
github.com/draffensperger/golp v0.0.0-20250721104811-2d405f0b4e68/go.mod h1:/TbDI9zua4CTUs81AOyDxnKAuvXX/SmOjonijHadP+k=
|
||||
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 h1:SCYMcCJ89LjRGwEa0tRluNRiMjZHalQZrVrvTbPh+qw=
|
||||
@@ -17,8 +21,14 @@ github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+tw
|
||||
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/nsf/termbox-go v0.0.0-20190817171036-93860e161317 h1:hhGN4SFXgXo61Q4Sjj/X9sBjyeSa2kdpaOzCO+8EVQw=
|
||||
github.com/nsf/termbox-go v0.0.0-20190817171036-93860e161317/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 h1:+iq7lrkxmFNBM7xx+Rae2W6uyPfhPeDWD+n+JgppptE=
|
||||
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be h1:QAcqgptGM8IQBC9K/RC4o+O9YmqEm0diQn9QmZw/0mU=
|
||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
20
helpers/slice.go
Normal file
20
helpers/slice.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package aoc
|
||||
|
||||
func CombinationsWithReplacement[T any](input []T, n int) [][]T {
|
||||
var helper func(int, int, []T)
|
||||
result := [][]T{}
|
||||
|
||||
helper = func(start int, remaining int, current []T) {
|
||||
if remaining == 0 {
|
||||
combination := make([]T, len(current))
|
||||
copy(combination, current)
|
||||
result = append(result, combination)
|
||||
return
|
||||
}
|
||||
for i := start; i < len(input); i++ {
|
||||
helper(i, remaining-1, append(current, input[i]))
|
||||
}
|
||||
}
|
||||
helper(0, n, []T{})
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user