1
0
Fork 0
advent2018/day2/p1.py

35 lines
654 B
Python
Executable File

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import collections
def count_id(input_str):
rep_two = 0
rep_three = 0
results = collections.Counter(input_str).most_common(5)
for idx, val in enumerate(results):
value = val[1]
if value == 2:
rep_two = 1
if value == 3:
rep_three = 1
return rep_two, rep_three
if __name__ == '__main__':
two = 0
three = 0
with open("input.txt") as fp:
line = fp.readline()
while line:
(a, b) = count_id(line)
two += a
three += b
line = fp.readline()
print(two * three)