16 lines
402 B
Python
16 lines
402 B
Python
import re
|
|
|
|
#2-5 m: mfvxmmm
|
|
regex = re.compile(r'(\d+)-(\d+) (\w): (\w+)', re.I)
|
|
items = (re.match(regex, x).groups() for x in open("input.txt"))
|
|
items = map(lambda x: [int(x[0]), int(x[1]), *x[2:]], items)
|
|
|
|
|
|
def in_range(lower, upper, char, string):
|
|
cnt_range = sum(1 for s in string if char == s)
|
|
return lower <= cnt_range <= upper
|
|
|
|
|
|
count = sum(1 for x in items if in_range(*x))
|
|
print(count)
|