summaryrefslogtreecommitdiffstats
path: root/aoc/tests/test_datastructures.py
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <tom@vanderlee.io>2023-12-04 10:40:34 +0100
committerGravatar Tom van der Lee <tom@vanderlee.io>2023-12-04 10:41:07 +0100
commite688c2b674fc7ad6a964a48df379e5abd01843a7 (patch)
treee73ee82805e5521463706d117bd036cc1ae13ac8 /aoc/tests/test_datastructures.py
parent1de244cfb7ef2017981402c7d1eaa1b5a0aa16b7 (diff)
download2023-e688c2b674fc7ad6a964a48df379e5abd01843a7.tar.gz
2023-e688c2b674fc7ad6a964a48df379e5abd01843a7.tar.bz2
2023-e688c2b674fc7ad6a964a48df379e5abd01843a7.zip
Day4
Diffstat (limited to 'aoc/tests/test_datastructures.py')
-rw-r--r--aoc/tests/test_datastructures.py63
1 files changed, 48 insertions, 15 deletions
diff --git a/aoc/tests/test_datastructures.py b/aoc/tests/test_datastructures.py
index 42cc44d..1c291cc 100644
--- a/aoc/tests/test_datastructures.py
+++ b/aoc/tests/test_datastructures.py
@@ -24,13 +24,26 @@ class TestCoordinate:
24 24
25 def test_neighbours(self): 25 def test_neighbours(self):
26 c = Coordinate(0, 0) 26 c = Coordinate(0, 0)
27 neighbours = {Coordinate(-1, 0), Coordinate(1, 0), Coordinate(0, -1), Coordinate(0, 1), 27 neighbours = {
28 Coordinate(-1, -1), Coordinate(-1, 1), Coordinate(1, -1), Coordinate(1, 1)} 28 Coordinate(-1, 0),
29 Coordinate(1, 0),
30 Coordinate(0, -1),
31 Coordinate(0, 1),
32 Coordinate(-1, -1),
33 Coordinate(-1, 1),
34 Coordinate(1, -1),
35 Coordinate(1, 1),
36 }
29 assert set(c.neighbours()) == neighbours 37 assert set(c.neighbours()) == neighbours
30 38
31 def test_neighbours_no_diagonal(self): 39 def test_neighbours_no_diagonal(self):
32 c = Coordinate(0, 0) 40 c = Coordinate(0, 0)
33 neighbours_no_diagonal = {Coordinate(-1, 0), Coordinate(1, 0), Coordinate(0, -1), Coordinate(0, 1)} 41 neighbours_no_diagonal = {
42 Coordinate(-1, 0),
43 Coordinate(1, 0),
44 Coordinate(0, -1),
45 Coordinate(0, 1),
46 }
34 assert set(c.neighbours(no_diagonal=True)) == neighbours_no_diagonal 47 assert set(c.neighbours(no_diagonal=True)) == neighbours_no_diagonal
35 48
36 49
@@ -57,23 +70,43 @@ class TestCoordinate3:
57 def test_neighbours(self): 70 def test_neighbours(self):
58 c = Coordinate3(0, 0, 0) 71 c = Coordinate3(0, 0, 0)
59 neighbours = { 72 neighbours = {
60 Coordinate3(-1, -1, -1), Coordinate3(-1, -1, 0), Coordinate3(-1, -1, 1), 73 Coordinate3(-1, -1, -1),
61 Coordinate3(-1, 0, -1), Coordinate3(-1, 0, 0), Coordinate3(-1, 0, 1), 74 Coordinate3(-1, -1, 0),
62 Coordinate3(-1, 1, -1), Coordinate3(-1, 1, 0), Coordinate3(-1, 1, 1), 75 Coordinate3(-1, -1, 1),
63 Coordinate3(0, -1, -1), Coordinate3(0, -1, 0), Coordinate3(0, -1, 1), 76 Coordinate3(-1, 0, -1),
64 Coordinate3(0, 0, -1), Coordinate3(0, 0, 1), 77 Coordinate3(-1, 0, 0),
65 Coordinate3(0, 1, -1), Coordinate3(0, 1, 0), Coordinate3(0, 1, 1), 78 Coordinate3(-1, 0, 1),
66 Coordinate3(1, -1, -1), Coordinate3(1, -1, 0), Coordinate3(1, -1, 1), 79 Coordinate3(-1, 1, -1),
67 Coordinate3(1, 0, -1), Coordinate3(1, 0, 0), Coordinate3(1, 0, 1), 80 Coordinate3(-1, 1, 0),
68 Coordinate3(1, 1, -1), Coordinate3(1, 1, 0), Coordinate3(1, 1, 1) 81 Coordinate3(-1, 1, 1),
82 Coordinate3(0, -1, -1),
83 Coordinate3(0, -1, 0),
84 Coordinate3(0, -1, 1),
85 Coordinate3(0, 0, -1),
86 Coordinate3(0, 0, 1),
87 Coordinate3(0, 1, -1),
88 Coordinate3(0, 1, 0),
89 Coordinate3(0, 1, 1),
90 Coordinate3(1, -1, -1),
91 Coordinate3(1, -1, 0),
92 Coordinate3(1, -1, 1),
93 Coordinate3(1, 0, -1),
94 Coordinate3(1, 0, 0),
95 Coordinate3(1, 0, 1),
96 Coordinate3(1, 1, -1),
97 Coordinate3(1, 1, 0),
98 Coordinate3(1, 1, 1),
69 } 99 }
70 assert set(c.neighbours()) == neighbours 100 assert set(c.neighbours()) == neighbours
71 101
72 def test_neighbours_no_diagonal(self): 102 def test_neighbours_no_diagonal(self):
73 c = Coordinate3(0, 0, 0) 103 c = Coordinate3(0, 0, 0)
74 neighbours_no_diagonal = { 104 neighbours_no_diagonal = {
75 Coordinate3(-1, 0, 0), Coordinate3(1, 0, 0), 105 Coordinate3(-1, 0, 0),
76 Coordinate3(0, -1, 0), Coordinate3(0, 1, 0), 106 Coordinate3(1, 0, 0),
77 Coordinate3(0, 0, -1), Coordinate3(0, 0, 1) 107 Coordinate3(0, -1, 0),
108 Coordinate3(0, 1, 0),
109 Coordinate3(0, 0, -1),
110 Coordinate3(0, 0, 1),
78 } 111 }
79 assert set(c.neighbours(no_diagonal=True)) == neighbours_no_diagonal 112 assert set(c.neighbours(no_diagonal=True)) == neighbours_no_diagonal