Solve 2016 days 6 to 8.
This commit is contained in:
25
2016/d6.py
Normal file
25
2016/d6.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from lib import *
|
||||
|
||||
data = open(0).read().strip()
|
||||
second = True
|
||||
|
||||
p = ""
|
||||
for row in zip(*data.splitlines()):
|
||||
counts = {}
|
||||
for l in LETTERS_LOWER:
|
||||
counts[l] = row.count(l)
|
||||
maxc = 0
|
||||
minc = 999
|
||||
c = ""
|
||||
for l, count in counts.items():
|
||||
if second:
|
||||
if count > 0 and count < minc:
|
||||
minc = count
|
||||
c = l
|
||||
else:
|
||||
if count > maxc:
|
||||
maxc = count
|
||||
c = l
|
||||
p += c
|
||||
|
||||
print(p)
|
||||
Reference in New Issue
Block a user