mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Solutions for day 5.
This commit is contained in:
1000
day5-input.txt
Normal file
1000
day5-input.txt
Normal file
File diff suppressed because it is too large
Load Diff
22
day5.py
Normal file
22
day5.py
Normal file
@@ -0,0 +1,22 @@
|
||||
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