16 lines
330 B
Plaintext
16 lines
330 B
Plaintext
|
#!/usr/bin/python3
|
||
|
|
||
|
import re
|
||
|
|
||
|
valid = 0
|
||
|
with open("input") as fh:
|
||
|
for ln in fh:
|
||
|
m = re.match(r"(\d+)-(\d+) (.): (.*)", ln)
|
||
|
(min, max, char, pw) = m.groups()
|
||
|
min = int(min)
|
||
|
max = int(max)
|
||
|
num = pw.count(char)
|
||
|
valid += min <= num <= max
|
||
|
print(min, max, char, pw, valid)
|
||
|
|