-
Notifications
You must be signed in to change notification settings - Fork 1
/
hst_hidden_subset_test.go
86 lines (73 loc) · 2.88 KB
/
hst_hidden_subset_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package sudoku
import (
"testing"
)
func TestSubsetCellsWithNUniquePossibilities(t *testing.T) {
grid := NewGrid()
grid, err := MutableLoadSDKFromFile(puzzlePath("hiddenpair1_filled.sdk"))
if err != nil {
t.Log("Failed to load hiddenpair1_filled.sdk")
t.Fail()
}
cells, nums := subsetCellsWithNUniquePossibilities(2, grid.Row(4))
if len(cells) != 1 {
t.Log("Didn't get right number of subset cells unique with n possibilities: ", len(cells))
t.FailNow()
}
cellList := cells[0]
numList := nums[0]
if len(cellList) != 2 {
t.Log("Number of subset cells did not match k: ", len(cellList))
t.Fail()
}
if cellList[0].Row != 4 || cellList[0].Col != 7 || cellList[1].Row != 4 || cellList[1].Col != 8 {
t.Log("Subset cells unique came back with wrong cells: ", cellList)
t.Fail()
}
if !numList.SameContentAs(IntSlice([]int{3, 5})) {
t.Error("Subset cells unique came back with wrong numbers: ", numList)
}
}
func TestHiddenPairRow(t *testing.T) {
options := solveTechniqueTestHelperOptions{
targetCells: []CellRef{{4, 7}, {4, 8}},
pointerCells: []CellRef{{4, 7}, {4, 8}},
targetSame: _GROUP_ROW,
targetGroup: 4,
targetNums: IntSlice([]int{7, 8, 2}),
pointerNums: IntSlice([]int{3, 5}),
description: "3 and 5 are only possible in (4,7) and (4,8) within row 4, which means that only those numbers could be in those cells",
}
humanSolveTechniqueTestHelper(t, "hiddenpair1_filled.sdk", "Hidden Pair Row", options)
techniqueVariantsTestHelper(t, "Hidden Pair Row")
}
func TestHiddenPairCol(t *testing.T) {
options := solveTechniqueTestHelperOptions{
transpose: true,
targetCells: []CellRef{{7, 4}, {8, 4}},
pointerCells: []CellRef{{7, 4}, {8, 4}},
targetSame: _GROUP_COL,
targetGroup: 4,
targetNums: IntSlice([]int{7, 8, 2}),
pointerNums: IntSlice([]int{3, 5}),
description: "3 and 5 are only possible in (7,4) and (8,4) within column 4, which means that only those numbers could be in those cells",
}
humanSolveTechniqueTestHelper(t, "hiddenpair1_filled.sdk", "Hidden Pair Col", options)
techniqueVariantsTestHelper(t, "Hidden Pair Col")
}
func TestHiddenPairBlock(t *testing.T) {
options := solveTechniqueTestHelperOptions{
targetCells: []CellRef{{4, 7}, {4, 8}},
pointerCells: []CellRef{{4, 7}, {4, 8}},
//Yes, in this case we want them to be the same row.
targetSame: _GROUP_ROW,
targetGroup: 4,
targetNums: IntSlice([]int{7, 8, 2}),
pointerNums: IntSlice([]int{3, 5}),
description: "3 and 5 are only possible in (4,7) and (4,8) within block 5, which means that only those numbers could be in those cells",
}
humanSolveTechniqueTestHelper(t, "hiddenpair1_filled.sdk", "Hidden Pair Block", options)
techniqueVariantsTestHelper(t, "Hidden Pair Block")
}
//TODO: Test HiddenTriple. The file I have on hand doesn't require the technique up front.
//TODO: Test HiddenQuad. The file I ahve on hand doesn't require the technique up front.