days 4, 5 and 6, not bad
This commit is contained in:
17
d05/run.py
Normal file
17
d05/run.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import sys
|
||||
|
||||
def isnice1(l):
|
||||
if any(a+b in ['ab','cd','pq','xy'] for (a,b) in zip(l,l[1:])):
|
||||
return False
|
||||
vowels = sum(c in 'aeiou' for c in l)
|
||||
inarow = any(a==b for (a,b) in zip(l,l[1:]))
|
||||
return vowels > 2 and inarow
|
||||
|
||||
def isnice2(l):
|
||||
xyxy = any(l[i:i+2] == l[j:j+2] for i in range(len(l)-1) for j in range(i+2,len(l)-1))
|
||||
gfg = any(a == b for a,b in zip(l[0:],l[2:]))
|
||||
return xyxy and gfg
|
||||
|
||||
isnice = isnice2 if sys.argv[1] == "2" else isnice1
|
||||
|
||||
print(sum(isnice(l[:-1]) for l in sys.stdin.readlines()))
|
Reference in New Issue
Block a user