Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Common Words by Mahoter
def checkio(first, second):
a = 0
b = 0
res = ""
words = []
while a <= len(first):
if first[a:a+1] == "," or a==len(first):
fword = first[b:a]
c = 0
d = 0
while c <= len(second):
if second[c:c+1] == "," or c==len(second):
sword = second[d:c]
if fword == sword:
words += [fword]
d = c+1
c+=1
b = a+1
a+=1
words.sort()
for w in words:
res += "," + w
res = res[1:len(res)]
return res
#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"
Jan. 17, 2016