Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Determine the Order by imloafer
from collections import OrderedDict
def checkio(data):
data = [''.join(OrderedDict.fromkeys(d)) for d in data]
# data = [''.join(ch for ch, _ in groupby(d)) for d in data]
unique_data = sorted(set(''.join(data)))
ans = ""
while unique_data:
for c in unique_data:
if not any(c in d[1:] for d in data):
ans += c
break
data = [d.replace(c,"") for d in data]
unique_data.remove(c)
return ans
# These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == "__main__":
checkio(["hello","low","lino","itttnosw"]) == 'helitnosw'
assert checkio(["xxxyyz","yyww","wwtt","ttzz"]) == "xywtz"
assert checkio(["hfecba","hgedba","hgfdca"]) == "hgfedcba"
assert (
checkio(["a", "b", "c"]) == "abc"
), "Cant determine the order - use english alphabet"
assert checkio(["dfg", "frt", "tyg"]) == "dfrtyg", "Concatenate and paste in"
assert checkio(["acb", "bd", "zwa"]) == "zwacbd", "Just concatenate it"
assert checkio(["aazzss"]) == "azs", "Each symbol only once"
assert checkio(["klm", "kadl", "lsm"]) == "kadlsm", "Paste in"
assert checkio(["is","not","abc","nots","iabcn"]) == 'iabcnots'
assert checkio(["qwerty","asdfg","zxcvb","yagz"]) == "qwertyasdfgzxcvb"
assert checkio(["jhgfdba","jihcba","jigedca"]) == "jihgefdcba"
Jan. 3, 2023
Comments: