Cody

# Problem 78. Implement a ROT13 cipher

Solution 865040

Submitted on 4 Apr 2016 by David Schafer
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))

str = 73 32 108 111 118 101 32 77 65 84 76 65 66 str = 86 32 121 111 118 101 32 77 65 84 76 65 66 str = 86 32 121 124 118 101 32 77 65 84 76 65 66 str = 86 32 121 98 131 101 32 77 65 84 76 65 66 str = 86 32 121 98 105 114 32 77 65 84 76 65 66

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

str = 73 32 60 51 32 77 65 84 76 65 66 33 33

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))

str = Columns 1 through 16 84 104 101 32 113 117 105 99 107 32 102 111 120 32 115 116 Columns 17 through 32 117 109 98 108 101 100 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 101 32 113 117 105 99 107 32 102 111 120 32 115 116 Columns 17 through 32 117 109 98 108 101 100 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 113 117 105 99 107 32 102 111 120 32 115 116 Columns 17 through 32 117 109 98 108 101 100 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 126 117 105 99 107 32 102 111 120 32 115 116 Columns 17 through 32 117 109 98 108 101 100 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 130 105 99 107 32 102 111 120 32 115 116 Columns 17 through 32 117 109 98 108 101 100 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 104 118 99 107 32 102 111 120 32 115 116 Columns 17 through 32 117 109 98 108 101 100 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 104 118 112 107 32 102 111 120 32 115 116 Columns 17 through 32 117 109 98 108 101 100 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 104 118 112 120 32 102 111 120 32 115 116 Columns 17 through 32 117 109 98 108 101 100 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 104 118 112 120 32 115 111 120 32 115 116 Columns 17 through 32 117 109 98 108 101 100 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 104 118 112 120 32 115 124 120 32 115 116 Columns 17 through 32 117 109 98 108 101 100 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 104 118 112 120 32 115 98 133 32 115 116 Columns 17 through 32 117 109 98 108 101 100 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 104 118 112 120 32 115 98 107 32 128 116 Columns 17 through 32 117 109 98 108 101 100 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 104 118 112 120 32 115 98 107 32 102 129 Columns 17 through 32 117 109 98 108 101 100 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 104 118 112 120 32 115 98 107 32 102 103 Columns 17 through 32 130 109 98 108 101 100 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 104 118 112 120 32 115 98 107 32 102 103 Columns 17 through 32 104 122 98 108 101 100 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 104 118 112 120 32 115 98 107 32 102 103 Columns 17 through 32 104 122 111 108 101 100 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 104 118 112 120 32 115 98 107 32 102 103 Columns 17 through 32 104 122 111 121 101 100 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 104 118 112 120 32 115 98 107 32 102 103 Columns 17 through 32 104 122 111 121 114 100 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 104 118 112 120 32 115 98 107 32 102 103 Columns 17 through 32 104 122 111 121 114 113 32 111 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 104 118 112 120 32 115 98 107 32 102 103 Columns 17 through 32 104 122 111 121 114 113 32 124 118 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 104 118 112 120 32 115 98 107 32 102 103 Columns 17 through 32 104 122 111 121 114 113 32 98 131 101 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 104 118 112 120 32 115 98 107 32 102 103 Columns 17 through 32 104 122 111 121 114 113 32 98 105 114 114 32 116 104 101 32 Columns 33 through 48 99 111 110 102 117 115 105 110 103 32 105 110 115 116 114 117 Columns 49 through 55 99 116 105 111 110 115 46 str = Columns 1 through 16 71 117 114 32 100 104 118 112 120 32 115 98 107 32 102 103 Columns 17 through 32 104 122 111 121 114 113 32 98 105 ...

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))

str = Columns 1 through 16 83 110 97 112 101 32 107 105 108 108 115 32 68 117 109 98 Columns 17 through 32 108 101 100 111 114 101 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 123 97 112 101 32 107 105 108 108 115 32 68 117 109 98 Columns 17 through 32 108 101 100 111 114 101 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 112 101 32 107 105 108 108 115 32 68 117 109 98 Columns 17 through 32 108 101 100 111 114 101 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 125 101 32 107 105 108 108 115 32 68 117 109 98 Columns 17 through 32 108 101 100 111 114 101 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 99 114 32 107 105 108 108 115 32 68 117 109 98 Columns 17 through 32 108 101 100 111 114 101 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 99 114 32 120 105 108 108 115 32 68 117 109 98 Columns 17 through 32 108 101 100 111 114 101 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 99 114 32 120 118 108 108 115 32 68 117 109 98 Columns 17 through 32 108 101 100 111 114 101 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 99 114 32 120 118 121 108 115 32 68 117 109 98 Columns 17 through 32 108 101 100 111 114 101 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 99 114 32 120 118 121 121 115 32 68 117 109 98 Columns 17 through 32 108 101 100 111 114 101 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 99 114 32 120 118 121 121 128 32 68 117 109 98 Columns 17 through 32 108 101 100 111 114 101 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 99 114 32 120 118 121 121 102 32 81 130 109 98 Columns 17 through 32 108 101 100 111 114 101 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 99 114 32 120 118 121 121 102 32 81 104 122 98 Columns 17 through 32 108 101 100 111 114 101 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 99 114 32 120 118 121 121 102 32 81 104 122 111 Columns 17 through 32 108 101 100 111 114 101 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 99 114 32 120 118 121 121 102 32 81 104 122 111 Columns 17 through 32 121 101 100 111 114 101 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 99 114 32 120 118 121 121 102 32 81 104 122 111 Columns 17 through 32 121 114 100 111 114 101 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 99 114 32 120 118 121 121 102 32 81 104 122 111 Columns 17 through 32 121 114 113 111 114 101 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 99 114 32 120 118 121 121 102 32 81 104 122 111 Columns 17 through 32 121 114 113 124 114 101 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 99 114 32 120 118 121 121 102 32 81 104 122 111 Columns 17 through 32 121 114 113 98 127 101 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 99 114 32 120 118 121 121 102 32 81 104 122 111 Columns 17 through 32 121 114 113 98 101 114 32 111 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 99 114 32 120 118 121 121 102 32 81 104 122 111 Columns 17 through 32 121 114 113 98 101 114 32 124 110 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 through 16 70 97 110 99 114 32 120 118 121 121 102 32 81 104 122 111 Columns 17 through 32 121 114 113 98 101 114 32 98 123 32 112 97 103 101 32 54 Columns 33 through 48 48 54 46 32 65 108 115 111 44 32 116 104 101 114 101 32 Columns 49 through 60 105 115 32 110 111 32 83 97 110 116 97 46 str = Columns 1 throug...

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!