first commit

This commit is contained in:
Peter Hudec
2018-12-13 19:09:30 +01:00
commit 9f3e899cda
9 changed files with 2750 additions and 0 deletions

33
02/solve01.py Executable file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env python
def read_input():
with open('input.txt', 'r') as f:
for line in f:
yield line
def get_count(box):
occ2 = 0
occ3 = 0
seen = dict()
for c in set(box):
if occ2 and occ3:
break
if box.count(c) == 2:
occ2 = 1
if box.count(c) == 3:
occ3 = 1
return (occ2,occ3)
res2 = 0
res3 = 0
for box in read_input():
(tmp2, tmp3) = get_count(box)
res2 += tmp2
res3 += tmp3
print(res2*res3)