Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Common Words by Angelika
def checkio(first, second):
tekst=""
a=""
i=0
j=0
k=0
n=0
m=0
tab1=[]
tab2=[]
wynik=[]
while len(first)>0:
a=""
while len(first)>0 and first[0]!=',':
a=a+first[0]
first=first[1:]
if len(first)>0:
first=first[1:]
tab1.append(a)
i=i+1
while len(second)>0:
a=""
while len(second)>0 and second[0]!=',':
a=a+second[0]
second=second[1:]
if len(second)>0:
second=second[1:]
tab2.append(a)
j=j+1
for n in range(i):
for m in range(j):
if tab1[n]==tab2[m]:
wynik.append(tab1[n])
k=k+1
break
wynik.sort()
for i in range(k):
tekst=tekst+wynik[i]+','
if len(tekst)>0:
tekst=tekst[0:len(tekst)-1]
return tekst
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio("hello,world", "hello,earth") == "hello", "Hello"
assert checkio("one,two,three", "four,five,six") == "", "Too different"
assert checkio("one,two,three", "four,five,one,two,six,three") == "one,three,two", "1 2 3"
Oct. 30, 2016