day22: bug: not using Set - duplicate supports
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package day22
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSpaceSettleSingle(t *testing.T) {
|
||||
filename := "example"
|
||||
@@ -104,3 +107,29 @@ func TestExampleSpacePrint(t *testing.T) {
|
||||
PrintSpace(space, "after-settping.png")
|
||||
|
||||
}
|
||||
|
||||
func TestCompareInitialAndBruteforce(t *testing.T) {
|
||||
filename := "input"
|
||||
blocks := ReadBlockFile(filename)
|
||||
byZ := BlocksByZ(blocks)
|
||||
|
||||
space := NewSpace(byZ)
|
||||
|
||||
space.SettleAll()
|
||||
|
||||
initialBlocks := space.InitialCollectGoodToDisintegrate()
|
||||
correct := space.ThirdTimeCollectGoodToDisintegrate()
|
||||
|
||||
t.Log("len of initial solution : ", len(initialBlocks))
|
||||
t.Log("len of correct solution : ", len(correct))
|
||||
|
||||
for _, disintegratableInInitial := range initialBlocks {
|
||||
indexInCorrect := slices.IndexFunc(correct, func(e Block) bool {
|
||||
return e.NameNum == disintegratableInInitial.NameNum
|
||||
})
|
||||
if indexInCorrect == -1 {
|
||||
t.Logf("> found %+v. falsly marked as disintegratable\n\n", disintegratableInInitial)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user