You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
686 B
Python
32 lines
686 B
Python
#!/usr/bin/env python3
|
|
|
|
with open('input.txt', 'r') as f:
|
|
package_ids = [x.strip() for x in f.readlines()]
|
|
|
|
# print(package_ids)
|
|
|
|
count_doubles = 0
|
|
count_tripples = 0
|
|
|
|
for el in package_ids:
|
|
is_double = False
|
|
is_tripple = False
|
|
|
|
for my_char in set(el):
|
|
count = el.count(my_char)
|
|
if count == 2:
|
|
is_double = True
|
|
if count == 3:
|
|
is_tripple = True
|
|
|
|
if is_double:
|
|
count_doubles += 1
|
|
if is_tripple:
|
|
count_tripples += 1
|
|
|
|
print('Entries:', len(package_ids))
|
|
print('Doubles:', count_doubles)
|
|
print('Tripples:', count_tripples)
|
|
print('-' * 40)
|
|
print('Checksum:', count_doubles * count_tripples)
|