18 lines
426 B
Python
18 lines
426 B
Python
|
#!/usr/bin/env python3
|
||
|
import re
|
||
|
pattern = re.compile('(\d+)-(\d+)\s(\w):\s(\w+)')
|
||
|
with open('input', 'r') as f:
|
||
|
content = list(map(str.strip, f.readlines()))
|
||
|
|
||
|
valid_pws = 0
|
||
|
for entry in content:
|
||
|
p1, p2, char, pw = re.match(pattern, entry).groups(1)
|
||
|
p1 = int(p1) - 1
|
||
|
p2 = int(p2) - 1
|
||
|
if pw[p1] == char and pw[p2] != char or pw[p1] != char and pw[p2] == char:
|
||
|
valid_pws += 1
|
||
|
|
||
|
|
||
|
print(valid_pws)
|
||
|
|