18 lines
413 B
Python
Executable File
18 lines
413 B
Python
Executable File
#!/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:
|
|
mini, maxi, char, pw = re.match(pattern, entry).groups(1)
|
|
mini = int(mini)
|
|
maxi = int(maxi)
|
|
char_count = pw.count(char)
|
|
if mini <= char_count <= maxi:
|
|
valid_pws += 1
|
|
|
|
print(valid_pws)
|
|
|