forked from aaronshaver/graph-unique-paths
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_puzzle.py
94 lines (82 loc) · 3.24 KB
/
test_puzzle.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
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
#!/usr/bin/python3
from puzzle import *
import unittest
class TestPuzzle(unittest.TestCase):
def setUp(self):
self.one_node_one_exit = {'a': ['aExit']}
self.two_nodes_two_exits = {
'a': ['b', 'aExit'],
'b': ['a', 'bExit']
}
self.three_nodes_two_exits = {
'a': ['b', 'c', 'aExit'],
'b': ['a', 'c', 'bExit'],
'c': ['a', 'b']
}
self.three_nodes_three_exits = {
'a': ['b', 'c', 'aExit'],
'b': ['a', 'c', 'bExit'],
'c': ['a', 'b', 'cExit']
}
self.four_nodes_three_exits = {
'a': ['b', 'c', 'd', 'aExit'],
'b': ['a', 'c', 'bExit'],
'c': ['d', 'b', 'a'],
'd': ['a', 'c', 'dExit']
}
self.four_nodes_four_exits = {
'a': ['b', 'c', 'd', 'aExit'],
'b': ['a', 'c', 'bExit'],
'c': ['d', 'b', 'a', 'cExit'],
'd': ['a', 'c', 'dExit']
}
self.four_nodes_four_exits_max_connections = {
'a': ['b', 'c', 'd', 'aExit'],
'b': ['a', 'c', 'd', 'bExit'],
'c': ['d', 'b', 'a', 'cExit'],
'd': ['a', 'c', 'b', 'dExit']
}
self.five_nodes_five_exits_max_connections = {
'a': ['b', 'c', 'd', 'e', 'aExit'],
'b': ['a', 'c', 'd', 'e', 'bExit'],
'c': ['d', 'b', 'a', 'e', 'cExit'],
'd': ['a', 'c', 'b', 'e', 'dExit'],
'e': ['a', 'c', 'b', 'd', 'eExit']
}
self.the_witness_seven_nodes_six_exits = {
'a': ['b', 'f', 'g' 'aExit'],
'b': ['a', 'c', 'g' 'bExit'],
'c': ['b', 'd', 'g' 'cExit'],
'd': ['c', 'e', 'g' 'dExit'],
'e': ['d', 'f', 'g' 'eExit'],
'f': ['e', 'a', 'g' 'fExit'],
'g': ['a', 'b' 'c', 'd', 'e', 'f']
}
self.puzzle = Puzzle()
def test_solve_single_node_single_exit(self):
self.assertEqual(1, len(self.puzzle.solve(
self.one_node_one_exit)))
def test_solve_two_nodes_two_exits(self):
self.assertEqual(4, len(self.puzzle.solve(
self.two_nodes_two_exits)))
def test_solve_three_nodes_two_exits(self):
self.assertEqual(10, len(self.puzzle.solve(
self.three_nodes_two_exits)))
def test_solve_three_nodes_three_exits(self):
self.assertEqual(15, len(self.puzzle.solve(
self.three_nodes_three_exits)))
def test_solve_four_nodes_three_exits(self):
self.assertEqual(32, len(self.puzzle.solve(
self.four_nodes_three_exits)))
def test_solve_four_nodes_four_exits(self):
self.assertEqual(42, len(self.puzzle.solve(
self.four_nodes_four_exits)))
def test_solve_four_nodes_four_exits_max_connections(self):
self.assertEqual(64, len(self.puzzle.solve(
self.four_nodes_four_exits_max_connections)))
def test_solve_five_nodes_five_exits_max_connections(self):
self.assertEqual(325, len(self.puzzle.solve(
self.five_nodes_five_exits_max_connections)))
def test_solve_the_witness_seven_nodes_six_exits(self):
self.assertEqual(116, len(self.puzzle.solve(
self.the_witness_seven_nodes_six_exits)))