22 lines
424 B
Python
22 lines
424 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))
|
|
if pline.count(pch) < pmin:
|
|
continue
|
|
if pline.count(pch) > pmax:
|
|
continue
|
|
valid +=1
|
|
|
|
print(valid) |