Day 6
This commit is contained in:
2084
day06/input.txt
Normal file
2084
day06/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
15
day06/part1.py
Normal file
15
day06/part1.py
Normal file
@@ -0,0 +1,15 @@
|
||||
lines = (set([c for c in x.strip()]) for x in open("input.txt"))
|
||||
|
||||
current = set()
|
||||
count = 0
|
||||
|
||||
|
||||
for line in lines:
|
||||
if len(line) == 0:
|
||||
print("x", len(current))
|
||||
count += len(current)
|
||||
current = set()
|
||||
current = current.union(line)
|
||||
count += len(current)
|
||||
|
||||
print(count)
|
||||
21
day06/part2.py
Normal file
21
day06/part2.py
Normal file
@@ -0,0 +1,21 @@
|
||||
lines = (set([c for c in x.strip()]) for x in open("input.txt"))
|
||||
|
||||
current = set()
|
||||
count = 0
|
||||
restart = True
|
||||
|
||||
|
||||
for line in lines:
|
||||
if len(line) == 0:
|
||||
count += len(current)
|
||||
current = set()
|
||||
restart = True
|
||||
continue
|
||||
if restart:
|
||||
current = line
|
||||
restart = False
|
||||
else:
|
||||
current = current.intersection(line)
|
||||
count += len(current)
|
||||
|
||||
print(count)
|
||||
Reference in New Issue
Block a user