Cody

Problem 751. Implement simple rotation cypher

Solution 1454561

Submitted on 2 Mar 2018 by shimon zusmanovsky
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
inStr = 'doug'; shift = 10; outStr = 'nyeq'; assert(isequal(cypher(inStr, shift),outStr))

outStr = [] x = 4 shift = 10 y = 110 w = 'n' outStr = 'n' y = 121 w = 'y' outStr = 'ny' y = 101 w = 'e' outStr = 'nye' y = 113 w = 'q' outStr = 'nyeq'

2   Pass
inStr = 'thequickbrownfox'; shift = 5; outStr = 'ymjvznhpgwtbsktc'; assert(isequal(cypher(inStr, shift),outStr))

outStr = [] x = 16 shift = 5 y = 121 w = 'y' outStr = 'y' y = 109 w = 'm' outStr = 'ym' y = 106 w = 'j' outStr = 'ymj' y = 118 w = 'v' outStr = 'ymjv' y = 122 w = 'z' outStr = 'ymjvz' y = 110 w = 'n' outStr = 'ymjvzn' y = 104 w = 'h' outStr = 'ymjvznh' y = 112 w = 'p' outStr = 'ymjvznhp' y = 103 w = 'g' outStr = 'ymjvznhpg' y = 119 w = 'w' outStr = 'ymjvznhpgw' y = 116 w = 't' outStr = 'ymjvznhpgwt' y = 98 w = 'b' outStr = 'ymjvznhpgwtb' y = 115 w = 's' outStr = 'ymjvznhpgwtbs' y = 107 w = 'k' outStr = 'ymjvznhpgwtbsk' y = 116 w = 't' outStr = 'ymjvznhpgwtbskt' y = 99 w = 'c' outStr = 'ymjvznhpgwtbsktc'

3   Pass
inStr = 'thecrowfliesatmidnight'; shift = 22; outStr = 'pdaynksbheaowpiezjecdp'; assert(isequal(cypher(inStr, shift),outStr))

outStr = [] x = 22 shift = 22 y = 112 w = 'p' outStr = 'p' y = 100 w = 'd' outStr = 'pd' y = 97 w = 'a' outStr = 'pda' y = 121 w = 'y' outStr = 'pday' y = 110 w = 'n' outStr = 'pdayn' y = 107 w = 'k' outStr = 'pdaynk' y = 115 w = 's' outStr = 'pdaynks' y = 98 w = 'b' outStr = 'pdaynksb' y = 104 w = 'h' outStr = 'pdaynksbh' y = 101 w = 'e' outStr = 'pdaynksbhe' y = 97 w = 'a' outStr = 'pdaynksbhea' y = 111 w = 'o' outStr = 'pdaynksbheao' y = 119 w = 'w' outStr = 'pdaynksbheaow' y = 112 w = 'p' outStr = 'pdaynksbheaowp' y = 105 w = 'i' outStr = 'pdaynksbheaowpi' y = 101 w = 'e' outStr = 'pdaynksbheaowpie' y = 122 w = 'z' outStr = 'pdaynksbheaowpiez' y = 106 w = 'j' outStr = 'pdaynksbheaowpiezj' y = 101 w = 'e' outStr = 'pdaynksbheaowpiezje' y = 99 w = 'c' outStr = 'pdaynksbheaowpiezjec' y = 100 w = 'd' outStr = 'pdaynksbheaowpiezjecd' y = 112 w = 'p' outStr = 'pdaynksbheaowpiezjecdp'