forked from halfrost/LeetCode-Go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path79. Word Search_test.go
105 lines (90 loc) · 1.62 KB
/
79. Word Search_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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package leetcode
import (
"fmt"
"testing"
)
type question79 struct {
para79
ans79
}
// para 是参数
// one 代表第一个参数
type para79 struct {
b [][]byte
word string
}
// ans 是答案
// one 代表第一个答案
type ans79 struct {
one bool
}
func Test_Problem79(t *testing.T) {
qs := []question79{
{
para79{[][]byte{
{'A', 'B', 'C', 'E'},
{'S', 'F', 'C', 'S'},
{'A', 'D', 'E', 'E'},
}, "ABCCED"},
ans79{true},
},
{
para79{[][]byte{
{'A', 'B', 'C', 'E'},
{'S', 'F', 'C', 'S'},
{'A', 'D', 'E', 'E'},
}, "SEE"},
ans79{true},
},
{
para79{[][]byte{
{'A', 'B', 'C', 'E'},
{'S', 'F', 'C', 'S'},
{'A', 'D', 'E', 'E'},
}, "ABCB"},
ans79{false},
},
{
para79{[][]byte{
{'o', 'a', 'a', 'n'},
{'e', 't', 'a', 'e'},
{'i', 'h', 'k', 'r'},
{'i', 'f', 'l', 'v'},
}, "oath"},
ans79{true},
},
{
para79{[][]byte{
{'o', 'a', 'a', 'n'},
{'e', 't', 'a', 'e'},
{'i', 'h', 'k', 'r'},
{'i', 'f', 'l', 'v'},
}, "pea"},
ans79{false},
},
{
para79{[][]byte{
{'o', 'a', 'a', 'n'},
{'e', 't', 'a', 'e'},
{'i', 'h', 'k', 'r'},
{'i', 'f', 'l', 'v'},
}, "eat"},
ans79{true},
},
{
para79{[][]byte{
{'o', 'a', 'a', 'n'},
{'e', 't', 'a', 'e'},
{'i', 'h', 'k', 'r'},
{'i', 'f', 'l', 'v'},
}, "rain"},
ans79{false},
},
}
fmt.Printf("------------------------Leetcode Problem 79------------------------\n")
for _, q := range qs {
_, p := q.ans79, q.para79
fmt.Printf("【input】:%v 【output】:%v\n\n\n", p, exist(p.b, p.word))
}
fmt.Printf("\n\n\n")
}