day 06 && 07

This commit is contained in:
2020-12-07 11:48:15 +01:00
parent 21fd6de1cd
commit 7c44fe57b3
9 changed files with 3132 additions and 0 deletions

46
day06/module.py Normal file
View File

@@ -0,0 +1,46 @@
from aoc.input import get_input
import collections
import re
from aoc.partselector import part_one, part_two
def pw(line):
return line.strip()
def p1():
inp = get_input(pw)
groups = []
group = []
for i in inp:
if i == '':
groups.append(group)
group = []
else:
group.append(i)
count = 0
for g in groups:
answers = set()
for p in g:
for x in p:
answers.add(x)
count += len(answers)
print(count)
return groups
def p2(r):
count = 0
for g in r:
s = set(g[0])
for p in g[1:]:
s = s.intersection(p)
count += len(s)
print(count)
return 0
if part_one():
result1 = p1()
if part_two():
p2(result1)