-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
69 lines (62 loc) · 1.29 KB
/
test.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
import unittest
from part_one import distance_to_closest_intersection
from part_two import steps_to_best_intersection
class TestDay3(unittest.TestCase):
def test_part1(self):
tests = [
(
[
'R75', 'D30', 'R83', 'U83', 'L12', 'D49', 'R71', 'U7', 'L72'
],
[
'U62', 'R66', 'U55', 'R34', 'D71', 'R55', 'D58', 'R83'
],
159
),
(
[
'R98', 'U47', 'R26', 'D63', 'R33', 'U87',
'L62', 'D20', 'R33', 'U53', 'R51'
],
[
'U98', 'R91', 'D20', 'R16', 'D67', 'R40', 'U7', 'R15', 'U6', 'R7'
],
135
)
]
for test in tests:
with self.subTest(test=test):
self.assertEqual(
distance_to_closest_intersection(test[0], test[1]),
test[2]
)
def test_part2(self):
tests = [
(
[
'R75', 'D30', 'R83', 'U83', 'L12', 'D49', 'R71', 'U7', 'L72'
],
[
'U62', 'R66', 'U55', 'R34', 'D71', 'R55', 'D58', 'R83'
],
610
),
(
[
'R98', 'U47', 'R26', 'D63', 'R33', 'U87',
'L62', 'D20', 'R33', 'U53', 'R51'
],
[
'U98', 'R91', 'D20', 'R16', 'D67', 'R40', 'U7', 'R15', 'U6', 'R7'
],
410
)
]
for test in tests:
with self.subTest(test=test):
self.assertEqual(
steps_to_best_intersection(test[0], test[1]),
test[2]
)
if __name__ == '__main__':
unittest.main()