SRM 233 DIV1

SRM 233 DIV1

I was just reading through a topcoder tutorial from the link:

How to find a solution

While I was reading the article, there was a paragraph which was discussing about SRM 233 DIV1 problem. SmartWordToy, replace the characters in the input such a way that it goes from input to output, without passing through forbidden words.

An idea/doubt striked, when I read this sentence:

With a single button click you can change any letter to the previous or next letter in alphabetical order (for example ‘c’ can be changed to ‘b’ or ‘d’). _The alphabet is circular, thus ‘a’ can become ‘z’, and ‘z’ can become ‘a’ with one click.

The italized statement is what struck me. So, if z can become a and a can become z in the alphabet. Then it is possible that in next step, z can be replaced with b and b with z, so at each step alphabet grows, so at each step, the actual rule to apply the logic changes. This would result in keeping track of each of the neighbours of a particular character in the alphabet and then applying the rule at each step.

Is it possible that a is trickling down from z towards its original position, but in the meantime, b meets z and y meets a and in the next step, b and y meet and so on so forth.

Written on April 2, 2015
comments powered by Disqus