advent-of-code/2015/day05/day05.py
germax26 dde31570ed
Add 2015/
With original solutions from when I did them.
2024-12-02 19:17:00 +11:00

27 lines
648 B
Python
Executable File

def read_from_file(file_name):
_file = open(file_name, 'r')
_read = _file.read().split('\n')
_file.close()
return _read
import re
words = read_from_file('inputs/day05.input')
def solve1():
total = 0
for word in words:
if re.match(r"(.*[aeiou]){3}.*", word) and re.match(r".*([a-z])\1.*", word) and not re.match(r".*(ab|cd|pq|xy).*", word):
total += 1
return total
def solve2():
total = 0
for word in words:
if re.match(r".*([a-z])([a-z]).*\1\2.*", word) and re.match(r".*([a-z]).\1.*", word):
total += 1
return total
print("Pt1:",solve1())
print("Pt2:",solve2())