The Resistance puzzle discussion


you are right …
the answer is 2
19 is definitely wrong


Great puzzle. At first glance it seemed quite easy to come up with good solution and it really is for the simple tests, small dictionary short word to decode. But when the time comes to solve the very hard tests, really good optimizations are needed. I needed quite some time and lots of thinking to find the right algorithm. At the end storing where each letter begins in the input string helped me for faster finding where each word from the dictionary begins. After that I used a recursion over the dictionary words and count how many words start at a given index of the input word and span to the end of the input string, that way I do not go through the how string every time.