Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by Rafal__Kotas
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
def checkio(text):
VOWELS = "AEIOUYaeiouy"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZbcdfghjklmnpqrstvwxz"
NUMBERS = "0123456789"
if(len(text)>1):
d=[]
y=''
ile=0
for i in range (len(text)+1):
if(i0) or (CONSONANTS.count(text[i])>0) or (NUMBERS.count(text[i])>0)):
y=y+text[i]
else:
d.append(y)
y=''
if(i==len(text)):
d.append(y)
print (d)
D=[]
#usuwanie słów zawierających cyfry
for i in range (len(d)):
prawda=1
for j in range (len(d[i])):
if(ord(d[i][j])>=48 and ord(d[i][j])<=57):
prawda=0
if(prawda==1):
D.append(d[i])
print(D)
#usuwanie pustych słów/kropek/przecinków
while(D.count('')>0):
D.remove('')
while(D.count(',')>0):
D.remove(',')
while(d.count('.')>0):
D.remove('.')
print (D)
y=''
l=[] #tablica 0-samogłoski,1-spółgłoski
for i in range(len(D)):
for j in range (len(D[i])):
for k in range (len(VOWELS)):
if(D[i][j]==VOWELS[k]):
y=y+'0'
for m in range (len(CONSONANTS)):
if((D[i][j])==CONSONANTS[m]):
y=y+'1'
l.append(y)
y=''
L=[]
for i in range(len(l)):
if(len(l[i])>1):
L.append(l[i])
print(l)
print(L)
for i in range(len(L)):
prawda1=1
prawda2=1
if(len(L[i])>1):
for j in range(len(L[i])-1):
if(L[i][j]==L[i][j+1]):
prawda1=0
if(prawda1==1):
ile=ile+1;
return (ile)
else:
return 0
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio("My name is ...") == 3, "All words are striped"
assert checkio("Hello world") == 0, "No one"
assert checkio("A quantity of striped words.") == 1, "Only of"
assert checkio("Dog,cat,mouse,bird.Human.") == 3, "Dog, cat and human"
Nov. 1, 2016