-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_day11.py
71 lines (61 loc) · 4.63 KB
/
test_day11.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
import unittest
from copy import deepcopy
from day11 import step, day11a, day11b
# fmt:off
exampleInput = [[5,4,8,3,1,4,3,2,2,3],[2,7,4,5,8,5,4,7,1,1],[5,2,6,4,5,5,6,1,7,3],[6,1,4,1,3,3,6,1,4,6],[6,3,5,7,3,8,5,4,7,8],[4,1,6,7,5,2,4,6,4,5],[2,1,7,6,8,4,1,7,2,1],[6,8,8,2,8,8,1,1,3,4],[4,8,4,6,8,4,8,5,5,4],[5,2,8,3,7,5,1,5,2,6]]
# fmt:on
class TestDay11(unittest.TestCase):
def test_stepSmall(self):
# fmt:off
grid00 = [[1,1,1,1,1],[1,9,9,9,1],[1,9,1,9,1],[1,9,9,9,1],[1,1,1,1,1]]
grid01 = [[3,4,5,4,3],[4,0,0,0,4],[5,0,0,0,5],[4,0,0,0,4],[3,4,5,4,3]]
grid02 = [[4,5,6,5,4],[5,1,1,1,5],[6,1,1,1,6],[5,1,1,1,5],[4,5,6,5,4]]
# fmt:on
gridNew, flashCount = step(grid00)
self.assertEqual(gridNew, grid01)
gridNew, flashCount = step(grid01)
self.assertEqual(gridNew, grid02)
# @unittest.skip("unimplemented")
def test_step(self):
# fmt:off
grid00 = [[5,4,8,3,1,4,3,2,2,3],[2,7,4,5,8,5,4,7,1,1],[5,2,6,4,5,5,6,1,7,3],[6,1,4,1,3,3,6,1,4,6],[6,3,5,7,3,8,5,4,7,8],[4,1,6,7,5,2,4,6,4,5],[2,1,7,6,8,4,1,7,2,1],[6,8,8,2,8,8,1,1,3,4],[4,8,4,6,8,4,8,5,5,4],[5,2,8,3,7,5,1,5,2,6]]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,0,6],[0,0,9,9,1,1,1,3,0,6],[0,0,9,3,5,1,1,2,3,3],[0,4,4,2,3,6,1,1,3,0],[5,5,3,2,2,5,2,3,5,0],[0,5,3,2,2,5,0,6,0,0],[0,0,3,2,2,4,0,0,0,0]]
# fmt:on
gridNew, flashCount = step(grid00)
self.assertEqual(gridNew, grid01)
gridNew, flashCount = step(grid01)
self.assertEqual(gridNew, grid02)
gridNew, flashCount = step(grid02)
self.assertEqual(gridNew, grid03)
gridNew, flashCount = step(grid03)
self.assertEqual(gridNew, grid04)
gridNew, flashCount = step(grid04)
self.assertEqual(gridNew, grid05)
gridNew, flashCount = step(grid05)
self.assertEqual(gridNew, grid06)
gridNew, flashCount = step(grid06)
self.assertEqual(gridNew, grid07)
gridNew, flashCount = step(grid07)
self.assertEqual(gridNew, grid08)
gridNew, flashCount = step(grid08)
self.assertEqual(gridNew, grid09)
gridNew, flashCount = step(grid09)
self.assertEqual(gridNew, grid10)
def test_day11a(self):
grid = deepcopy(exampleInput)
self.assertEqual(day11a(grid), 1656)
# @unittest.skip("unimplemented")
def test_day11b(self):
grid = deepcopy(exampleInput)
self.assertEqual(day11b(grid), 195)
if __name__ == "__main__":
unittest.main()