Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Determine the Order by berinchik10
def checkio(data):
result= ''
s = sorted(set().union(*data))
while s:
for char in s :
if all(char not in word or char == word[0] for word in data):
result +=char
s=[j for j in s if j!=char]
for i in range(len(data)):
data[i] =data[i].replace(char, "")
break
print(result)
return result
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio(["acb", "bd", "zwa"]) == "zwacbd", \
"Just concatenate it"
assert checkio(["klm", "kadl", "lsm"]) == "kadlsm", \
"Paste in"
assert checkio(["a", "b", "c"]) == "abc", \
"Cant determine the order - use english alphabet"
assert checkio(["aazzss"]) == "azs", \
"Each symbol only once"
assert checkio(["dfg", "frt", "tyg"]) == "dfrtyg", \
"Concatenate and paste in"
April 27, 2021