Cody

# Problem 78. Implement a ROT13 cipher

Solution 1766076

Submitted on 29 Mar 2019 by Samatha Aleti
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
s1 = 'I love MATLAB'; s2_correct = 'V ybir ZNGYNO'; assert(isequal(rot13(s1),s2_correct))

repset1 = 'nopqrstuvwxyzabcdefghijklm' repset2 = 'NOPQRSTUVWXYZABCDEFGHIJKLM' check1 = 1×0 empty double row vector check2 = 9 s2 = 'V' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 12 check2 = 1×0 empty double row vector s2 = 'V y' check1 = 15 check2 = 1×0 empty double row vector s2 = 'V yb' check1 = 22 check2 = 1×0 empty double row vector s2 = 'V ybi' check1 = 5 check2 = 1×0 empty double row vector s2 = 'V ybir' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 1×0 empty double row vector check2 = 13 s2 = 'V ybir Z' check1 = 1×0 empty double row vector check2 = 1 s2 = 'V ybir ZN' check1 = 1×0 empty double row vector check2 = 20 s2 = 'V ybir ZNG' check1 = 1×0 empty double row vector check2 = 12 s2 = 'V ybir ZNGY' check1 = 1×0 empty double row vector check2 = 1 s2 = 'V ybir ZNGYN' check1 = 1×0 empty double row vector check2 = 2 s2 = 'V ybir ZNGYNO'

2   Pass
s1 = 'I <3 MATLAB!!'; s2_correct = 'V <3 ZNGYNO!!'; assert(isequal(rot13(s1),s2_correct))

repset1 = 'nopqrstuvwxyzabcdefghijklm' repset2 = 'NOPQRSTUVWXYZABCDEFGHIJKLM' check1 = 1×0 empty double row vector check2 = 9 s2 = 'V' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 1×0 empty double row vector check2 = 13 s2 = 'V <3 Z' check1 = 1×0 empty double row vector check2 = 1 s2 = 'V <3 ZN' check1 = 1×0 empty double row vector check2 = 20 s2 = 'V <3 ZNG' check1 = 1×0 empty double row vector check2 = 12 s2 = 'V <3 ZNGY' check1 = 1×0 empty double row vector check2 = 1 s2 = 'V <3 ZNGYN' check1 = 1×0 empty double row vector check2 = 2 s2 = 'V <3 ZNGYNO' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector

3   Pass
s1 = 'The quick fox stumbled over the confusing instructions.'; s2_correct = 'Gur dhvpx sbk fghzoyrq bire gur pbashfvat vafgehpgvbaf.'; assert(isequal(rot13(s1),s2_correct))

repset1 = 'nopqrstuvwxyzabcdefghijklm' repset2 = 'NOPQRSTUVWXYZABCDEFGHIJKLM' check1 = 1×0 empty double row vector check2 = 20 s2 = 'G' check1 = 8 check2 = 1×0 empty double row vector s2 = 'Gu' check1 = 5 check2 = 1×0 empty double row vector s2 = 'Gur' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 17 check2 = 1×0 empty double row vector s2 = 'Gur d' check1 = 21 check2 = 1×0 empty double row vector s2 = 'Gur dh' check1 = 9 check2 = 1×0 empty double row vector s2 = 'Gur dhv' check1 = 3 check2 = 1×0 empty double row vector s2 = 'Gur dhvp' check1 = 11 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 6 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx s' check1 = 15 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sb' check1 = 24 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 19 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk f' check1 = 20 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fg' check1 = 21 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fgh' check1 = 13 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghz' check1 = 2 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzo' check1 = 12 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoy' check1 = 5 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyr' check1 = 4 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 15 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq b' check1 = 22 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bi' check1 = 5 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bir' check1 = 18 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 20 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire g' check1 = 8 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gu' check1 = 5 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 3 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur p' check1 = 15 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pb' check1 = 14 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pba' check1 = 6 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pbas' check1 = 21 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pbash' check1 = 19 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pbashf' check1 = 9 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pbashfv' check1 = 14 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pbashfva' check1 = 7 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pbashfvat' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 9 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pbashfvat v' check1 = 14 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pbashfvat va' check1 = 19 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pbashfvat vaf' check1 = 20 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pbashfvat vafg' check1 = 18 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pbashfvat vafge' check1 = 21 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pbashfvat vafgeh' check1 = 3 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pbashfvat vafgehp' check1 = 20 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pbashfvat vafgehpg' check1 = 9 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pbashfvat vafgehpgv' check1 = 15 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pbashfvat vafgehpgvb' check1 = 14 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pbashfvat vafgehpgvba' check1 = 19 check2 = 1×0 empty double row vector s2 = 'Gur dhvpx sbk fghzoyrq bire gur pbashfvat vafgehpgvbaf' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector

4   Pass
s1 = 'Snape kills Dumbledore on page 606. Also, there is no Santa.'; s2_correct = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyfb, gurer vf ab Fnagn.'; assert(isequal(rot13(s1),s2_correct))

repset1 = 'nopqrstuvwxyzabcdefghijklm' repset2 = 'NOPQRSTUVWXYZABCDEFGHIJKLM' check1 = 1×0 empty double row vector check2 = 19 s2 = 'F' check1 = 14 check2 = 1×0 empty double row vector s2 = 'Fa' check1 = 1 check2 = 1×0 empty double row vector s2 = 'Fan' check1 = 16 check2 = 1×0 empty double row vector s2 = 'Fanc' check1 = 5 check2 = 1×0 empty double row vector s2 = 'Fancr' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 11 check2 = 1×0 empty double row vector s2 = 'Fancr x' check1 = 9 check2 = 1×0 empty double row vector s2 = 'Fancr xv' check1 = 12 check2 = 1×0 empty double row vector s2 = 'Fancr xvy' check1 = 12 check2 = 1×0 empty double row vector s2 = 'Fancr xvyy' check1 = 19 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 1×0 empty double row vector check2 = 4 s2 = 'Fancr xvyyf Q' check1 = 21 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qh' check1 = 13 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhz' check1 = 2 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzo' check1 = 12 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoy' check1 = 5 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyr' check1 = 4 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrq' check1 = 15 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqb' check1 = 18 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqbe' check1 = 5 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 15 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber b' check1 = 14 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 16 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba c' check1 = 1 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cn' check1 = 7 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cnt' check1 = 5 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cntr' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 1×0 empty double row vector check2 = 1 s2 = 'Fancr xvyyf Qhzoyrqber ba cntr 606. N' check1 = 12 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Ny' check1 = 19 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyf' check1 = 15 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyfb' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 20 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyfb, g' check1 = 8 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyfb, gu' check1 = 5 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyfb, gur' check1 = 18 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyfb, gure' check1 = 5 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyfb, gurer' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 9 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyfb, gurer v' check1 = 19 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyfb, gurer vf' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 14 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyfb, gurer vf a' check1 = 15 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyfb, gurer vf ab' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector check1 = 1×0 empty double row vector check2 = 19 s2 = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyfb, gurer vf ab F' check1 = 1 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyfb, gurer vf ab Fn' check1 = 14 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyfb, gurer vf ab Fna' check1 = 20 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyfb, gurer vf ab Fnag' check1 = 1 check2 = 1×0 empty double row vector s2 = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyfb, gurer vf ab Fnagn' check1 = 1×0 empty double row vector check2 = 1×0 empty double row vector