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.

20 lines
415 B
Python

4 years ago
"""
Solution to 2020/01
"""
COUNT = 0
with open('input', 'r') as file:
for line in file.readlines():
rule, char, password = line.strip().split()
char = char[0]
pos_1, pos_2 = rule.split('-')
pos_1 = int(pos_1) - 1
pos_2 = int(pos_2) - 1
is_valid = (password[pos_1] == char) ^ (password[pos_2] == char)
if is_valid:
COUNT += 1
print(COUNT)