-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
54 lines (44 loc) · 1.04 KB
/
utils.py
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
def print_puzzle(puzzle):
print("---------")
for line in puzzle:
print("| ", end="")
for n in line:
print(n, end=" ")
print("|")
print("---------")
def check_input(state):
if len(state) != 3:
return False
for line in state:
if len(line) != 3:
return False
for x in line:
if not isinstance(x, int):
return False
return True
# test cases
test = []
test.append([[1, 2, 3],
[4, 5, 6],
[7, 8, 0]])
test.append([[1, 2, 3],
[4, 5, 6],
[0, 7, 8]])
test.append([[1, 2, 3],
[5, 0, 6],
[4, 7, 8]])
test.append([[1, 3, 6],
[5, 0, 2],
[4, 7, 8]])
test.append([[1, 3, 6],
[5, 0, 7],
[4, 8, 2]])
test.append([[1, 6, 7],
[5, 0, 3],
[4, 8, 2]])
test.append([[7, 1, 2],
[4, 8, 5],
[6, 3, 0]])
test.append([[0, 7, 2],
[4, 6, 1],
[3, 5, 8]])