Problem 78. Implement a ROT13 cipher
Solution Stats
Problem Comments

3 Comments
Why does the "t" not change in the second word of the second test? The correct answer has an unchanged "t"?
I'm wondering the same thing. The letters in the second word are not rotated!
OK, I see that the '& l t ;' is the < symbol, therefore, the group of four chars should stay together and not be changed, but that requires an interpretation of the input string as opposed to using the input string as is.
Solution Comments

1 Comment
Why this code is doesnt pass though it gives me proper ans in matlab
in = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890;,.!& '
out = 'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm1234567890;,.!& '
s2 = s1
for i=1:length(s1)
x= find(in == s1(i)) ;
s2(i) = out(x)
end
specialcase = find(s2 == '&')
if ~isempty(specialcase)
s2(specialcase)='

1 Comment
Nice problem. Also like the encoder and decoder are the same (ROT13 applied twice gives back the original text).

2 Comments

1 Comment
Sorry, mistake in crediting comment in code; this solution is based on Jan's solution (Solution 17079)  not Jan Orwat's solution.

1 Comment
A modification of Solution 819585.

2 Comments
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/78implementarot13cipher/solutions/1275889

2 Comments
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.
Problem Recent Solvers1044
Suggested Problems

Return a list sorted by number of occurrences
1786 Solvers

1497 Solvers

Flag largest magnitude swings as they occur
625 Solvers

Given a window, how many subsets of a vector sum positive
799 Solvers

Relative ratio of "1" in binary number
662 Solvers
More from this Author95
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!