Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Words Order solution in Clear category for Words Order by JimmyCarlos
# 2 Flavours for you.
def words_order(text: str, words: list) -> bool:
if any(word not in text.split() for word in words): return False
A = [text.split().index(word) for word in words]
if any(a>=b for a,b in zip(A,A[1:])): return False
return True
def words_order(text: str, words: list) -> bool:
if len(set(words)) < len(words): return False
text_words = text.split()
for word in words:
if word in text_words:
text_words = text_words[text_words.index(word)+1:]
else:
return False
return True
May 26, 2020
Comments: