1
0
Fork 0
advent-of-code/2015/aoc_d5p1.py

44 lines
765 B
Python
Raw Normal View History

2024-02-08 09:55:40 +01:00
#!/usr/bin/env python
total = 0
with open("inputd5.txt", "r") as f:
for line in f:
vowels = 0
previous_letter = ""
double_letter = False
for c in line:
naughty = False
if c in ["a", "e", "i", "o", "u"]:
vowels += 1
if c == previous_letter:
double_letter = True
if (previous_letter == "a" and c == "b"):
naughty = True
if (previous_letter == "c" and c == "d"):
naughty = True
if (previous_letter == "p" and c == "q"):
naughty = True
if (previous_letter == "x" and c == "y"):
naughty = True
if (naughty):
break
previous_letter = c
if (naughty == False and vowels >= 3 and double_letter == True):
total += 1
double_letter = False
previous_letter = ""
vowels = 0
print(total)