mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Move 2015 out of the way.
This commit is contained in:
23
2015/day-05/solution.py
Normal file
23
2015/day-05/solution.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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.")
|
||||
Reference in New Issue
Block a user