day 10 part 2 solution!
This commit is contained in:
parent
17ce57943c
commit
74b7c774d6
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user