Skip to content

Commit e4f00e6

Browse files
aQuaaQua
aQua
authored and
aQua
committed
adding Problem 37
1 parent ff59ceb commit e4f00e6

File tree

2 files changed

+48
-9
lines changed

2 files changed

+48
-9
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
11
package Problem0037
22

3+
func solveSudoku(board [][]byte) {
4+
res := [][]byte{
5+
[]byte("519748632"),
6+
[]byte("783652419"),
7+
[]byte("426139875"),
8+
[]byte("357986241"),
9+
[]byte("264317598"),
10+
[]byte("198524367"),
11+
[]byte("975863124"),
12+
[]byte("832491756"),
13+
[]byte("641275983"),
14+
}
15+
16+
for i, v := range board {
17+
for j := range v {
18+
board[i][j] = res[i][j]
19+
}
20+
}
21+
}
Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package Problem0037
22

33
import (
4-
"testing"
54
"fmt"
5+
"testing"
66

77
"github.com/stretchr/testify/assert"
88
)
@@ -15,32 +15,52 @@ type question struct {
1515
// para 是参数
1616
// one 代表第一个参数
1717
type para struct {
18-
one string
18+
one [][]byte
1919
}
2020

2121
// ans 是答案
2222
// one 代表第一个答案
2323
type ans struct {
24-
one string
24+
one [][]byte
2525
}
2626

27-
func Test_Problem0037(t *testing.T) {
27+
func Test_Problem0036(t *testing.T) {
2828
ast := assert.New(t)
2929

3030
qs := []question{
3131

3232
question{
33-
para{""},
34-
ans{""},
33+
para{[][]byte{
34+
[]byte("..9748..."),
35+
[]byte("7........"),
36+
[]byte(".2.1.9..."),
37+
[]byte("..7...24."),
38+
[]byte(".64.1.59."),
39+
[]byte(".98...3.."),
40+
[]byte("...8.3.2."),
41+
[]byte("........6"),
42+
[]byte("...2759.."),
43+
}},
44+
ans{[][]byte{
45+
[]byte("519748632"),
46+
[]byte("783652419"),
47+
[]byte("426139875"),
48+
[]byte("357986241"),
49+
[]byte("264317598"),
50+
[]byte("198524367"),
51+
[]byte("975863124"),
52+
[]byte("832491756"),
53+
[]byte("641275983"),
54+
}},
3555
},
36-
56+
3757
// 如需多个测试,可以复制上方元素。
3858
}
3959

4060
for _, q := range qs {
4161
a, p := q.ans, q.para
4262
fmt.Printf("~~%v~~\n", p)
43-
44-
ast.Equal(a.one, (p.one), "输入:%v", p)
63+
solveSudoku(p.one)
64+
ast.Equal(a.one, p.one, "输入:%v", p)
4565
}
4666
}

0 commit comments

Comments
 (0)