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)
|