mirror of
https://github.com/Crocmagnon/advent-of-code.git
synced 2024-11-25 07:58:11 +01:00
Solve day 6
This commit is contained in:
parent
f233d1121e
commit
6ab0ae77f2
4 changed files with 2121 additions and 0 deletions
29
2020/day05-customs-declaration.py
Normal file
29
2020/day05-customs-declaration.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
from typing import List
|
||||
|
||||
|
||||
def main(filename: str, expected_part_1: int = None, expected_part_2: int = None):
|
||||
print(f"\n+ Running on {filename}")
|
||||
with open(filename) as f:
|
||||
groups = f.read().strip().split("\n\n") # type: List[str]
|
||||
|
||||
counter_part_1 = 0
|
||||
counter_part_2 = 0
|
||||
for group in groups:
|
||||
counter_part_1 += len(set(group.replace("\n", "")))
|
||||
people = group.split()
|
||||
intersect = set.intersection(*list(map(set, people)))
|
||||
counter_part_2 += len(intersect)
|
||||
|
||||
print(f"1. Found {counter_part_1}")
|
||||
if expected_part_1:
|
||||
assert expected_part_1 == counter_part_1
|
||||
|
||||
print(f"2. Found {counter_part_2}")
|
||||
if expected_part_2:
|
||||
assert expected_part_2 == counter_part_2
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main("inputs/day06-test1", 11, 6)
|
||||
main("inputs/day06-test2", 15, 8)
|
||||
main("inputs/day06", 6170, 2947)
|
2057
2020/inputs/day06
Normal file
2057
2020/inputs/day06
Normal file
File diff suppressed because it is too large
Load diff
15
2020/inputs/day06-test1
Normal file
15
2020/inputs/day06-test1
Normal file
|
@ -0,0 +1,15 @@
|
|||
abc
|
||||
|
||||
a
|
||||
b
|
||||
c
|
||||
|
||||
ab
|
||||
ac
|
||||
|
||||
a
|
||||
a
|
||||
a
|
||||
a
|
||||
|
||||
b
|
20
2020/inputs/day06-test2
Normal file
20
2020/inputs/day06-test2
Normal file
|
@ -0,0 +1,20 @@
|
|||
abc
|
||||
|
||||
a
|
||||
b
|
||||
c
|
||||
|
||||
ab
|
||||
ac
|
||||
|
||||
a
|
||||
a
|
||||
a
|
||||
a
|
||||
|
||||
b
|
||||
|
||||
ab
|
||||
ab
|
||||
abc
|
||||
abd
|
Loading…
Reference in a new issue