The Case of the Desperate Mastermind

Problem #289

Tags: unlabeled

Who solved this?

No translations... yet

This problem is a sequel to The Adventure of Morse Code; it is not, however, required that you have solved, or, for that matter, read that one. The problem was created by Vladimir V. Zelevinsky - for which we are much thankful!

"I think Moriarty is getting desperate," said Holmes one day. "He developed a new approach to generating his secret codes. Take a look at this intercepted telegram, Watson."

.----.....-..---..-...-.-...--.-...-.--.-.....--.....-.-....--.-........-...--..-.---.--.-......--.......-..-.---.....--.--..-....-.--.-....-.-.-...-.....--.-.-.-.-......-.-...---..-.-...-..---.--..-..

"This looks like Morse code," I said, "without any breaks between letters or words."

"That is correct," said Holmes. "To summarize what is already known: Moriarty is using sequences of between ten and thirteen words, inclusively, consisting only of the words that can be found in A Study in Scarlet. As a matter of fact, he now only uses words of five letters or more. However, these sequences of words are not consecutive. For example, a word 'elementary', repeated ten times, would be a perfectly valid secret code, even though it's only used in the text once."

"Hmm," I said. "What if a given code allows multiple interpretations?"

"Given that Moriarty values his henchpeople," said Holmes, "but also given his deplorable habit of feeding those who give him a wrong code to his pet aardvark, I think we can safely assume that each code has a unique translation."

"Is that even possible?" I said. "I wonder if there are multiple English words that look the same in Morse code - if the letters are glued together, of course."

"You don't need to wonder," said Holmes with, perhaps, a touch of irritation. "Anyone with half of a brain can quickly consider some common words and deduce that, yes, there are such duplicates. I trust it's obvious that, for example, the words 'usual' and 'fierce' form such a pair, as do the words 'refer' and 'leave', as well as many others. I think we can rely on Moriarty not using any of such words."

"But," I said, "even with these restrictions, the number of possible sequences might be in billions!"

"Considerably more, Watson," remarked Holmes. "Since there are 4796 different words in the text linked above that satisfy the requirements of having at least five letters and not being Morse duplicates -"

"How do you know that, Holmes?" I interrupted.

Holmes stared at me coldly.

"I don't know how one can enjoy a piece of fiction," he said, "if, while reading, one does not count the number of unique words one encounters. But back to our codes. It's clear that the number of possible ten-word sequences alone is 4796 to the tenth power, which is, obviously," and he paused for half a second, "6438604433038176701496641231782936576. There are, naturally, many more longer sequences. All you need to do is try them all."

I stared at him in horror. "Do I?!"

Holmes smiled.

"Perhaps you don't," he said. "The sequence above, for example, translates as follows."

ambitious cunning bunsen depths reproach wisely bungling barts buckle street galloped

"Perhaps you can try to decode the sequence below yourself? If you need a refresher on Morse code, the table can be found in the account of our previous adventure."

Note: input data, sample above and the answer - all of them are single line, even if broken into several lines when rendering in the browser!

You need to login to get test data and submit solution.