From b0d0306926f0fbc58368b9192bf738ffa3f3ae1b Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 4 Dec 2018 00:31:26 +0100 Subject: [PATCH] test scope fix/sudoku test formatting This commit fixes a bug in test scopes related to solveInit. Also fixes documentation placement in sudoku_test --- internal/xo/s.go | 5 +++-- sudoku_test.go | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/internal/xo/s.go b/internal/xo/s.go index 7873382..a7c29b9 100644 --- a/internal/xo/s.go +++ b/internal/xo/s.go @@ -635,8 +635,9 @@ func (s *S) cleanupSolve() { drvd := s.Driver.Derive(s.x) if drvd.TargetLevel < s.endTestLevel { trail.Back(s.endTestLevel) - s.x = CNull - //break + trail.Assign(drvd.Unit, drvd.P) + s.x = trail.Prop() + continue } trail.Back(drvd.TargetLevel) trail.Assign(drvd.Unit, drvd.P) diff --git a/sudoku_test.go b/sudoku_test.go index 675b57e..171ea31 100644 --- a/sudoku_test.go +++ b/sudoku_test.go @@ -99,14 +99,15 @@ func Example_sudoku() { } } fmt.Printf("\n") - // Output: 5 2 9 1 3 6 7 4 8 - // 4 3 1 7 8 5 2 9 6 - // 8 7 6 4 9 2 1 3 5 - // 1 6 3 2 4 8 5 7 9 - // 2 4 5 9 1 7 8 6 3 - // 7 9 8 5 6 3 4 1 2 - // 6 5 4 3 2 1 9 8 7 - // 3 1 2 8 7 9 6 5 4 - // 9 8 7 6 5 4 3 2 1 + } + // Output: 5 2 9 1 3 6 7 4 8 + // 4 3 1 7 8 5 2 9 6 + // 8 7 6 4 9 2 1 3 5 + // 1 6 3 2 4 8 5 7 9 + // 2 4 5 9 1 7 8 6 3 + // 7 9 8 5 6 3 4 1 2 + // 6 5 4 3 2 1 9 8 7 + // 3 1 2 8 7 9 6 5 4 + // 9 8 7 6 5 4 3 2 1 }