We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Wow, first I created a list with all the words, it worked for the example, but the validation has strings that are VERY long so my code was slow. I then realized I just need to count how many letters are in between the starting points and the end of the word.
like for Banana, let's say starting point is the first "a"
possible words:
a
an
ana
anan
anana
--> add 5 to score = len(string[start:]) or len(range(start, N))
The Minion Game
You are viewing a single comment's thread. Return to all comments →
Wow, first I created a list with all the words, it worked for the example, but the validation has strings that are VERY long so my code was slow. I then realized I just need to count how many letters are in between the starting points and the end of the word.
like for Banana, let's say starting point is the first "a"
possible words: a an ana anan anana
--> add 5 to score = len(string[start:]) or len(range(start, N))
which is much more efficient.