24 lines
729 B
Python
24 lines
729 B
Python
with open('puzzle.txt', 'r') as f:
|
|
strings = f.read().splitlines()
|
|
|
|
nice_strings = 0
|
|
vowels = ['a', 'e', 'i', 'o', 'u']
|
|
naughty_strings = ['ab', 'cd', 'pq', 'xy']
|
|
|
|
for string in strings:
|
|
|
|
if not any(naughty_bit in string for naughty_bit in naughty_strings):
|
|
vowel_count = 0
|
|
string_list = list(string)
|
|
for vowel in vowels:
|
|
for character in string_list:
|
|
if character == vowel:
|
|
vowel_count += 1
|
|
|
|
if vowel_count >= 3:
|
|
for character_idx in range(len(string_list) - 1):
|
|
if string_list[character_idx] == string_list[character_idx + 1]:
|
|
nice_strings += 1
|
|
break
|
|
|
|
print(nice_strings) |