[quote="[Community Puzzle] The Michelangelo Code, post:19, topic:190722"]
There are several ways to pick out letters from the sample text - every second letter, every third letter, every fourth letter, etc. You want to build each of those only once, rather than building each one over again for every word in the list. You want to only consider arrangements that have a real chance - if the text is only 400 characters, and all the words in the list are at least 4 characters, then considering âevery 200th letterâ is a waste of time.
[/quote]
Yes, thatâs why my step varies from 0 to len(text)//len(word). In your example, if the text is 400 with words of 4, I test the step from 0 to 100. Am I understanding correctly?
Yes, you seem to understand the idea of not trying step sizes that are too large. But do you just generate all possible steps through the text once, or do you effectively rebuild all the possible steps for each word in the list?
It is ignored in the sense that no matter how you change the case (uppercase/lowercase) of the input string, your code should still produce the same output.
My code:
First I remove all non-alphabetical char from text, and lowercase remaining ones.
Then for each word:
find first letter of word in text
for each position found
given word length and remaining text length, compute all possible steps (space between letters of word)
for each âstepâ, check if word if found in text
Among all words found in text, print text with the longest one, capitalizing evenly spaced letters from word.
Thanks a lot! Your custom case helps me find the error in my implementation. I was exiting main loop when first letter of word is not present in text instead of just skip this word and moving to next one.
Help! I pass all test cases, but my code fails on Validator 4 - Tempus Fugit. I donât think itâs a timeout issue, but maybe. Any ideas on how I can check? Thanks!