adventofcode-2020/02/part1

16 lines
330 B
Plaintext
Raw Permalink Normal View History

2020-12-12 13:10:55 +01:00
#!/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)