DRM Messages

From programming_contest
Jump to navigation Jump to search

This problem asks you to apply a series of string manipulations.

Note that for implementation, it's easy to work with a char array than a string, and much faster.

For rotation, you cannot do this step by step, but need to explicitly calculate. You do this by just modding by half the string length, and then explicitly moving chars to where they need to be. If you want to be super fancy, you can use array copies, but this shouldn't matter.

For rotating chars, you mod again, but by 26.

we can also make things super easy by using ascii math. You can treat chars just like numbers!

char new_char = ((old_char-'A' + rotation) %26)+'A'

Awesome.