Editorial for WC '16 Finals J2 - Enigmoo
Submitting an official solution before solving the problem yourself is a bannable offence.
Overall, we want to iterate over each of the words, and determine whether or not it can correspond to the encrypted message. If so, then we can increment a running total of possible words, which we'll output at the end.
To determine whether or not a given word is valid, we need to consider each possible value of between and (remembering to exclude ), and check if at least one such value would result in the encrypted word matching . If multiple values would work (which is the case when is made up entirely of ?
characters), we need to make sure to still only count the word once!
Finally, determining whether a given value of makes a certain word valid involves checking whether all of its characters are independently valid. For each index from to , we need to compute the value of when it's cyclically shifted forward in the alphabet by spots, and check whether that value is equal to . However, if is equal to ?
, then index should instead be skipped, as any original character at that index would be valid.
Comments