[Community Puzzle] The Michelangelo Code

Based on your example you are not checking the distance between the letters.
You need to look for for evenly spaced letters.

Second test case:

To be or not to be that is the question Whe (ignored)

Thertisnoblerinthemindtosuffe
Rtheslingsandarrowsofoutrageo
Usfortuneortotakearmsagainsta
Seaoftroublesandbyopposingend
T

hem To die to sleep No more and by a sleep to say we end The heartache and the thousand natural shocks That flesh is heir to (ignored)

1 Like

Hello,
I pass the 5 tests but the fourth validator takes too long in Python. An idea ?

Look at this earlier comment:

[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?

the uppercases are converted to lowercase not ignored :neutral_face:

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.

1 Like

It doesn’t say to ignore uppercase letters; it says to ignore capitalization.

1 Like

i guess you re right just having it next to the character that will get removed confused me and i wasted some time trying to figured it out

I pass all tests, but fails validator #1 and #4.
It’s very frustrating. Any hint?

Describe what your current code does (don’t give full code, just describe it) so we can see what hints can be given.

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.

Sounds all right to me, looks like there may be bugs in the implementation.

Try this custom case. It is similar to Validator 1 but not the same.

wartime advert in the midwest of the state
4
protection
width
bide
curfews

The output should be:

WartImeaDverTintH

1 Like

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.

2 Likes