advent/2015/5/sol.py
2022-11-06 13:55:53 -06:00

41 lines
730 B
Python

files = [i.rstrip() for i in open("input").readlines()]
def naughtyornice(string):
# do the vowel scan
vowels = "aeiou"
vowelcount = 0
for i in string:
if i in vowels:
vowelcount += 1
if vowelcount < 3:
return False
# double letter thing
last = None
containsdouble = False
for i in string:
if i == last:
containsdouble = True
break
last = i
if not containsdouble:
return False
# naughty doubles check
for i in ['ab', 'cd', 'pq', 'xy']:
if i in string:
return False
return True
nicecount = 0
for i in files:
if naughtyornice(i):
nicecount += 1
print(nicecount)