adventofcode-2020/02/part2

17 lines
394 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)
(first, second, char, pw) = m.groups()
first = int(first)
second = int(second)
check = pw[first-1] + pw[second-1]
num = check.count(char)
valid += num == 1
print(first, second, char, pw, check, valid)