aoc/2018/02/02.py
2021-05-13 08:05:13 -05:00

18 lines
465 B
Python

def read_file():
with open("input.txt","r") as f:
return f.read().split('\n')
def part1(boxes):
from collections import Counter as C
counts = [C(box) for box in boxes]
hasTwo = len([1 for count in counts if 2 in count.values()])
hasThree = len([1 for count in counts if 3 in count.values()])
return hasTwo * hasThree
def main():
boxes = read_file()
print(f'Part 1: {part1(boxes)}')
# print(f'Part 2: {part2(boxes)}')
if __name__ == "__main__":
main()