Complete day 6
This commit is contained in:
parent
47d19bfb2c
commit
b814c563a6
|
@ -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)
|
|
@ -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)
|
Loading…
Reference in New Issue