20 lines
405 B
Python
20 lines
405 B
Python
#!/usr/bin/env python
|
|
|
|
import re
|
|
|
|
RE_LINE = re.compile("^(\d+)-(\d+)\s+(.):\s+(.*)$")
|
|
|
|
valid = 0
|
|
with open("input01.txt","r") as f:
|
|
for line in f:
|
|
m = RE_LINE.match(line.strip())
|
|
if not m:
|
|
print(line)
|
|
continue
|
|
(pmin, pmax) = (int(m.group(1)), int(m.group(2)))
|
|
(pch, pline) = (m.group(3), m.group(4))
|
|
tmp = pline[pmin-1] + pline[pmax-1]
|
|
if tmp.count(pch) == 1:
|
|
valid +=1
|
|
|
|
print(valid) |