Complete day 6

This commit is contained in:
Peter J. Holzer 2020-12-13 16:20:12 +01:00 committed by Peter J. Holzer
parent 47d19bfb2c
commit b814c563a6
3 changed files with 2241 additions and 0 deletions

2211
06/input Normal file

File diff suppressed because it is too large Load Diff

14
06/part1 Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/python3
import string
sum = 0
with open("input") as fh:
groups = fh.read().split("\n\n")
for g in groups:
yes = set()
for c in g:
if c in string.ascii_lowercase:
yes.add(c)
sum += len(yes)
print(sum)

16
06/part2 Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/python3
import string
sum = 0
with open("input") as fh:
groups = fh.read().split("\n\n")
for g in groups:
g = g.strip()
g_yes = set(string.ascii_lowercase)
for p in g.split("\n"):
p_yes = set(p)
g_yes = g_yes & p_yes
sum += len(g_yes)
print(g.replace("\n", "."), g_yes, sum)
print(sum)