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
456 B
Python
20 lines
456 B
Python
"""
|
|
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]
|
|
min_occurence, max_occurence = rule.split('-')
|
|
min_occurence = int(min_occurence)
|
|
max_occurence = int(max_occurence)
|
|
|
|
is_valid = min_occurence <= password.count(char) <= max_occurence
|
|
|
|
if is_valid:
|
|
COUNT += 1
|
|
|
|
print(COUNT)
|