Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
The End of Other solution in Clear category for The End of Other by MadCow234
# migrated from python 2.7
def checkio(words_set):
# Loop through the words_set comparing each word to every other word.
for word1 in words_set:
for word2 in words_set:
# Return True if word1 is a suffix of word2.
# Second parameter of 1 ensures that True will not be returned
# for the case when word1 == word2.
if word2.endswith(word1, 1):
return True
return False
#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"
Aug. 12, 2014
Comments: