Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The End of Other by viktor.pecheniuk
# migrated from python 2.7
def checkio(word_set):
ws = sorted(w[::-1] for w in word_set)
return any(y.startswith(x) for x, y in zip(ws[:-1], ws[1:]))
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio({"hello", "lo", "he"}) == True, "helLO"
assert checkio({"hello", "la", "hellow", "cow"}) == False, "hellow la cow"
assert checkio({"walk", "duckwalk"}) == True, "duck to walk"
assert checkio({"one"}) == False, "Only One"
assert checkio({"helicopter", "li", "he"}) == False, "Only end"
Nov. 26, 2014
Comments: