From 74b7c774d6a0d5ef5a959b418a126b14802d0ede Mon Sep 17 00:00:00 2001 From: Andrew Ekstedt Date: Wed, 17 Dec 2025 22:25:55 +0000 Subject: [PATCH] day 10 part 2 solution! --- day10/sol2.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/day10/sol2.go b/day10/sol2.go index 74d1d0a..374669d 100644 --- a/day10/sol2.go +++ b/day10/sol2.go @@ -229,11 +229,19 @@ func solveJolts(target Jolts, pool []uint32) int { mask := this.jolts.BitSlice(bit) log.Printf("jolts = %v, bit = %d, mask = %0*b", this.jolts, bit, ntargets, mask) + // We can't short circuit mask==0 + // Consider this set of buttons: + // (2) (0,3,4,5,6,7) (0,4,5,6,7) (1,2,3,5) (0,1,2,3,4,6,7) (0,2,3,5) {42,20,50,40,32,36,32,32} + // with masks 100 11111001 11110001 101110 11011111 101101. + // There is no way to combine the buttons that results in mask 00000101 + // but! there is a way to press them that results in the zero mask 00000000 + // and has joltage 2,2,2,2,2,2,2,2 + // (press the third, fourth and fifth button) + // if we use that solution for the low bits then for the next bits + // we have to find 11111010 instead, which is possible (the second, fourth, and sixth buttons) + if mask == 0 { seen[this.jolts] = false - this.mask += 1 - qu.AddNode(this) - continue } for _, n := range bitcost.best(mask) {