-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_day12.py
50 lines (48 loc) · 1.29 KB
/
test_day12.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
import day12
import unittest
class Day12(unittest.TestCase):
def test_part1(self):
lines = """
???.### 1,1,3
.??..??...?##. 1,1,3
?#?#?#?#?#?#?#? 1,3,1,6
????.#...#... 4,1,1
????.######..#####. 1,6,5
?###???????? 3,2,1
"""
self.assertEqual(day12.solvePart1(lines.splitlines()), 21)
def test_countMatches(self):
tests = [
("#.#.### 1,1,3", 1),
("???.### 1,1,3", 1),
(".??..??...?##. 1,1,3", 4),
("?#?#?#?#?#?#?#? 1,3,1,6", 1),
("????.#...#... 4,1,1", 1),
("????.######..#####. 1,6,5", 4),
("?###???????? 3,2,1", 10),
]
for test in tests:
self.assertEqual(day12.countMatches(test[0]), test[1])
def test_countMatchesUnFolded(self):
tests = [
("???.### 1,1,3", 1),
(".??..??...?##. 1,1,3", 16384),
("?#?#?#?#?#?#?#? 1,3,1,6", 1),
("????.#...#... 4,1,1", 16),
("????.######..#####. 1,6,5", 2500),
("?###???????? 3,2,1", 506250),
]
for test in tests:
self.assertEqual(day12.countMatchesUnFolded(test[0]), test[1])
def test_part2(self):
lines = """
???.### 1,1,3
.??..??...?##. 1,1,3
?#?#?#?#?#?#?#? 1,3,1,6
????.#...#... 4,1,1
????.######..#####. 1,6,5
?###???????? 3,2,1
"""
self.assertEqual(day12.solvePart2(lines.splitlines()), 525152)
if __name__ == '__main__':
unittest.main()