mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 12:50:32 +01:00
24 lines
564 B
Python
24 lines
564 B
Python
from __future__ import print_function
|
|
import fileinput
|
|
import re
|
|
|
|
nice1 = 0
|
|
nice2 = 0
|
|
|
|
doubleletter = re.compile(r"(.)\1")
|
|
vowels = re.compile(r"[aeiou]")
|
|
forbidden = re.compile(r"ab|cd|pq|xy")
|
|
|
|
inbetween = re.compile(r"(.).\1")
|
|
twodouble = re.compile(r"(.)(.)(.*?)\1\2")
|
|
|
|
for line in fileinput.input():
|
|
if len(vowels.findall(line)) >= 3 and doubleletter.search(line) and not forbidden.search(line):
|
|
nice1 += 1
|
|
|
|
if inbetween.search(line) and twodouble.search(line):
|
|
nice2 += 1
|
|
|
|
print(nice1, "nice1 strings.")
|
|
print(nice2, "nice2 strings.")
|