Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 190405

Submitted on 13 Jan 2013 by Khaled Hamed

Correct

61Size
Leading solution size is 11.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
inString1 = 'I am ready to try it - with punctuation and CAPS!';
outString1a = 'F xj obxav ql qov fq - tfqe mrkzqrxqflk xka ZXMP!';
assert(isequal(simpleDecoderRing(inString1,-3),outString1a ));
i =
  Columns 1 through 16
     3     4     6     7     8     9    10    12    13    15    16    17    19    20    24    25
  Columns 17 through 32
    26    27    29    30    31    32    33    34    35    36    37    38    39    41    42    43
j =
     1    45    46    47    48
2
Pass
 
%%
inString1 = 'I am ready to try it - with punctuation and CAPS!';
outString1b = 'L dp uhdgb wr wub lw - zlwk sxqfwxdwlrq dqg FDSV!';
assert(isequal(simpleDecoderRing(inString1,3),outString1b ));
i =
  Columns 1 through 16
     3     4     6     7     8     9    10    12    13    15    16    17    19    20    24    25
  Columns 17 through 32
    26    27    29    30    31    32    33    34    35    36    37    38    39    41    42    43
j =
     1    45    46    47    48
3
Pass
 
%%
inString2 = 'Dick Tracy is often associated with decoder rings.';
outString2a = 'Lqks Bzikg qa wnbmv iaawkqibml eqbp lmkwlmz zqvoa.';
assert(isequal(simpleDecoderRing(inString2,-18),outString2a ));
i =
  Columns 1 through 16
     2     3     4     7     8     9    10    12    13    15    16    17    18    19    21    22
  Columns 17 through 32
    23    24    25    26    27    28    29    30    32    33    34    35    37    38    39    40
  Columns 33 through 40
    41    42    43    45    46    47    48    49
j =
     1     6
4
Pass
 
%%
inString2 = 'Dick Tracy is often associated with decoder rings.';
outString2b = 'Zeyg Pnwyu eo kbpaj wookyewpaz sepd zaykzan nejco.';
assert(isequal(simpleDecoderRing(inString2,22),outString2b ));
i =
  Columns 1 through 16
     2     3     4     7     8     9    10    12    13    15    16    17    18    19    21    22
  Columns 17 through 32
    23    24    25    26    27    28    29    30    32    33    34    35    37    38    39    40
  Columns 33 through 40
    41    42    43    45    46    47    48    49
j =
     1     6