-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_.py
More file actions
205 lines (155 loc) · 6.78 KB
/
test_.py
File metadata and controls
205 lines (155 loc) · 6.78 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
import boggle
from boggle import *
def test():
def test_calcul_point():
ma_grille = input("Nth size grid: ")
for i in range (4):
mot = input('Word: ')
point = calcul_point(ma_grille, mot)
taille_mot = len(mot)
taille_grille = len(ma_grille)
print("le mot de taille", taille_mot, 'donne', point, 'point(s)', 'pour une grille de taille', taille_grille)
#test_calcul_point()
def test_max_points():
score = ['jouer1', '13', 'joueur2', '15', 'jouer3', '13', 'joueur4', '15', 'jouer5', '13', 'joueur6', '15']
print(max_points(score, 6))
#test_max_points()
def test_dans_grille():
grille = [ ['G', 'A', 'W'], ['H', 'G', 'D'], ['G', 'Z', 'I'] ]
print(dans_grille(grille, 'HGAWIZ'))
#test_dans_grille()
def test_dans_grille():
grille = [ ['G', 'A', 'W', 'P'], ['H', 'G', 'D', 'W'], ['K', 'G', 'Z', 'I'], ['H', 'V', 'Q', 'W']]
print(dans_grille(grille, 'GGHAGVWIZ'))
#test_dans_grille()
def test_dans_grille():
grille = [ ['G', 'A', 'W'], ['H', 'G', 'H'], ['G', 'Z', 'I'] ]
assert(dans_grille(grille, 'HH' )) == [[3,5],[3,5]], 'the indices..'
#test_dans_grille()
def test_dans_grille():
#assert dans_grille(grille = [['A', 'D', 'N'], ['W', 'A', 'I'], ['A', 'L', 'E']], mot = 'DANIEL') == [1, [0, 4, 6], 2, 5, 8, 7]
#assert dans_grille(grille = [['A', 'D', 'N'], ['L', 'A', 'I'], ['A', 'L', 'E']], mot = 'DANIEL') == [1, [0, 4, 6], 2, 5, 8, [3,7]]
print(dans_grille(grille = [['A', 'D', 'N'], ['L', 'A', 'I'], ['A', 'L', 'E']], mot = 'DANIEL'))
#test_dans_grille()
def test_dans_grille():
grille = [['T', 'M', 'U', 'J' ], ['G', 'D', 'S', 'P'], [ 'Q', 'O', 'E', 'J'], ['J', 'O', 'N', 'J']]
mot = 'MUSJ'
assert(dans_grille(grille, mot)) == [1, 2, 6, [3, 11, 12, 15]]
#test_dans_grille()
def test_generer_des():
Des = generer_des(3)
print(Des)
#test_generer_des()
def test_est_adjacente():
grille = [['M', 'W', 'F', 'Z'], ['J', 'M', 'Q', 'D'], ['I', 'X', 'N', 'W'], ['S', 'L', 'I', 'I']]
word = 'ZDWI'
#position_matrix = dans_grille(grille, word)
#assert(position_matrix) == [3, 7, [1, 11], [8, 14, 15]]
assert(est_adjacente(grille, word)) == True
test_est_adjacente()
def test_est_adjacente():
grille = [['D', 'X', 'M', 'B'], ['M', 'E', 'P', 'E'], ['J', 'W', 'H', 'T'], ['W', 'V', 'A', 'E']]
#assert (dans_grille(grille, 'DEHE')) == [0, [5, 7, 15], 10, [5, 7, 15]], 'check'
#dessiner_grille(4, grille)
words = ['MXME', 'MXMB']
for word in words:
#position_matrix = dans_grille(grille, word)
#print(position_matrix)
assert(est_adjacente(grille, word)) == True, 'Check that out!!'
#print(est_adjacente(grille, word))
test_est_adjacente()
def test_est_adjacente():
grille = [['K', 'V', 'U', 'D'], ['U', 'X', 'P', 'N'], ['C', 'M', 'H', 'Q'], ['X', 'N', 'Z', 'M']]
word = 'KUCXNZM'
#print(est_adjacente(grille, word))
assert(est_adjacente(grille, word)) == True
test_est_adjacente()
def test_est_adjacente():
grille = [['U', 'M', 'L', 'C'], ['Z', 'C', 'Z', 'C'], ['L', 'R', 'F', 'L'], ['D', 'E', 'O', 'O']]
word = 'ZCZC'
assert(est_adjacente(grille, word)) == True, 'Because two same letters reapeat themself in a line'
test_est_adjacente()
def test_est_adjacente():
grille = [['B', 'H', 'H', 'Q'], ['F', 'Z', 'Y', 'D'], ['X', 'T', 'U', 'V'], ['K', 'J', 'Z', 'M']]
word = 'BHHQ'
assert(est_adjacente(grille, word)) == True, 'Because two same letters are adjacent'
test_est_adjacente()
def test_est_adjacente():
grille = [['C', 'Z', 'V', 'T', 'X'], ['S', 'P', 'A', 'B', 'U'], ['P', 'R', 'P', 'L', 'O'], ['D', 'K', 'B', 'B', 'N'], ['K', 'Z', 'N', 'M', 'C']]
word = 'CNOUX'
assert(est_adjacente(grille, word)) == True, 'check that'
#print(est_adjacente(grille, word))
test_est_adjacente()
def test_est_adjacente():
grille = [['O', 'V', 'C', 'L', 'F'], ['L', 'T', 'A', 'A', 'I'], ['Y', 'B', 'B', 'U', 'S'], ['H', 'O', 'I', 'A', 'L'], ['S', 'J', 'E', 'A', 'U']]
word = 'OTCLF'
assert(est_adjacente(grille, word)) == True
#print(est_adjacente(grille, word))
test_est_adjacente()
def test_est_adjacente():
grille = [['K', 'T'], ['A', 'U']]
word = 'AUTK'
assert(est_adjacente(grille, word)) == True ,'Because 0 as an index was considered as False so we take the string of adjacence'
#print(est_adjacente(grille, word))
test_est_adjacente()
def test_get_neighboor():
def test_coins():
grid5 = [0, 4, 20, 24]
for i in grid5:
print(i, 'has indices', get_neighboor('ABCDE', i))
grid4 = [0, 3, 15, 12]
for i in grid4:
print(i, 'has indices', get_neighboor('ABCD', i))
grid3 = [0, 2, 6, 8]
for i in grid3:
print(i, 'has indices', get_neighboor('ABC', i))
def test_millieu_colonne():
grid5 = [5, 9, 10, 14, 15, 19]
for i in grid5:
print(i, 'has indices', get_neighboor('ABCDE', i))
grid4 = [4, 8, 7, 11]
for i in grid4:
print(i, 'has indices', get_neighboor('ABCD', i))
grid3 = [3, 5]
for i in grid3:
print(i, 'has indices', get_neighboor('ABC', i))
return
def test_centre():
grid5 = [6, 7, 8, 11, 12, 13, 16, 17, 18]
#for i in grid5:
#print(i, 'has indices', get_neighboor('ABCDE', i))
grid4 = [5, 6, 9, 10]
for i in grid4:
print(i, 'has indices', get_neighboor('ABCD', i))
grid3 = [4]
for i in grid3:
print(i, 'has indices', get_neighboor('ABC', i))
return
return
def test_milieu_ligne():
grid5 = [1, 2, 3, 21, 22, 23]
for i in grid5:
print(i, 'has indices', get_neighboor('ABCDE', i))
grid4 = [13, 14]
for i in grid4:
print(i, 'has indices', get_neighboor('ABCD', i))
grid3 = [1, 7]
for i in grid3:
print(i, 'has indices', get_neighboor('ABC', i))
return
#test_coins()
#test_millieu_colonne()
#test_centre()
#test_milieu_ligne()
#test_get_neighboor()
test()
#une grille 4x4
#-----------------
#| C | Q | D | J |
#-----------------
#| A | A | E | K |
#-----------------
#| I | K | S | V |
#-----------------
#| J | T | F | U |
#-----------------