added day 06

This commit is contained in:
Peter Hudec 2021-12-14 22:20:48 +01:00
parent bd3ebf4e09
commit 8af76033f7
4 changed files with 2225 additions and 0 deletions

2178
06/input01.txt Normal file

File diff suppressed because it is too large Load Diff

15
06/input01_sample.txt Normal file
View File

@ -0,0 +1,15 @@
abc
a
b
c
ab
ac
a
a
a
a
b

15
06/solve01.py Normal file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env python
ans_yes = 0
with open("input01.txt","r") as f:
answers = ""
for line in f:
line = line.strip()
if len(line) == 0:
ans_yes += len(set(answers))
answers = ""
continue
answers += line
ans_yes += len(set(answers))
print(ans_yes)

17
06/solve02.py Normal file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env python
import string
ans_yes = 0
with open("input01.txt","r") as f:
answers = set(string.ascii_lowercase)
for line in f:
line = line.strip()
if len(line) == 0:
ans_yes += len(answers)
answers = set(string.ascii_lowercase)
continue
answers = answers.intersection(set(line))
ans_yes += len(answers)
print(ans_yes)