Replace each character in string s1 with the character that is shifted 13 positions from it (wrap back to the beginning if necessary). So A ? N, B ? O, and so on until Y ? L and Z ? M. Case of the output should match the case of the input, so a ? n. Non-alphabetic characters are left in place and untouched.
If
s1 = 'I love MATLAB'
then
s2 = 'V ybir ZNGYNO'
See the Wikipedia article for more info.
Why does the "t" not change in the second word of the second test? The correct answer has an unchanged "t"?
Nice problem. Also like the encoder and decoder are the same (ROT13 applied twice gives back the original text).
A small solution that doesn't use "regexp"!
Sorry, mistake in crediting comment in code; this solution is based on Jan's solution (Solution 17079) -- not Jan Orwat's solution.
A modification of Solution 819585.
Not my best work :/
It's still interesting to see other logical approaches like this, though.
One thing that can be done is to remove the inner "if" statements, as illustrated in Solution 1275889. https://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher/solutions/1275889
How does this work?
It is an old trick. You can pass any group of commands wrapped in a regexp command as one string. It used to be fun and can be used virtually for any problem, but I no longer use it since it is against the purpose of Cody.
Getting the absolute index from a matrix
176 Solvers
468 Solvers
MATCH THE STRINGS (2 CHAR) very easy
193 Solvers
302 Solvers
The sum of the numbers in the vector
341 Solvers