Cody

Problem 751. Implement simple rotation cypher

Solution 2102462

Submitted on 22 Jan 2020 by anan jeraise
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 = 'doug' ev = 110 outStr = 'noug' ev = 121 outStr = 'nyug' ev = 127 ev = 101 outStr = 'nyeg' ev = 113 outStr = 'nyeq'

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

outStr = 'thequickbrownfox' ev = 121 outStr = 'yhequickbrownfox' ev = 109 outStr = 'ymequickbrownfox' ev = 106 outStr = 'ymjquickbrownfox' ev = 118 outStr = 'ymjvuickbrownfox' ev = 122 outStr = 'ymjvzickbrownfox' ev = 110 outStr = 'ymjvznckbrownfox' ev = 104 outStr = 'ymjvznhkbrownfox' ev = 112 outStr = 'ymjvznhpbrownfox' ev = 103 outStr = 'ymjvznhpgrownfox' ev = 119 outStr = 'ymjvznhpgwownfox' ev = 116 outStr = 'ymjvznhpgwtwnfox' ev = 124 ev = 98 outStr = 'ymjvznhpgwtbnfox' ev = 115 outStr = 'ymjvznhpgwtbsfox' ev = 107 outStr = 'ymjvznhpgwtbskox' ev = 116 outStr = 'ymjvznhpgwtbsktx' ev = 125 ev = 99 outStr = 'ymjvznhpgwtbsktc'

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

outStr = 'thecrowfliesatmidnight' ev = 138 ev = 112 outStr = 'phecrowfliesatmidnight' ev = 126 ev = 100 outStr = 'pdecrowfliesatmidnight' ev = 123 ev = 97 outStr = 'pdacrowfliesatmidnight' ev = 121 outStr = 'pdayrowfliesatmidnight' ev = 136 ev = 110 outStr = 'pdaynowfliesatmidnight' ev = 133 ev = 107 outStr = 'pdaynkwfliesatmidnight' ev = 141 ev = 115 outStr = 'pdaynksfliesatmidnight' ev = 124 ev = 98 outStr = 'pdaynksbliesatmidnight' ev = 130 ev = 104 outStr = 'pdaynksbhiesatmidnight' ev = 127 ev = 101 outStr = 'pdaynksbheesatmidnight' ev = 123 ev = 97 outStr = 'pdaynksbheasatmidnight' ev = 137 ev = 111 outStr = 'pdaynksbheaoatmidnight' ev = 119 outStr = 'pdaynksbheaowtmidnight' ev = 138 ev = 112 outStr = 'pdaynksbheaowpmidnight' ev = 131 ev = 105 outStr = 'pdaynksbheaowpiidnight' ev = 127 ev = 101 outStr = 'pdaynksbheaowpiednight' ev = 122 outStr = 'pdaynksbheaowpieznight' ev = 132 ev = 106 outStr = 'pdaynksbheaowpiezjight' ev = 127 ev = 101 outStr = 'pdaynksbheaowpiezjeght' ev = 125 ev = 99 outStr = 'pdaynksbheaowpiezjecht' ev = 126 ev = 100 outStr = 'pdaynksbheaowpiezjecdt' ev = 138 ev = 112 outStr = 'pdaynksbheaowpiezjecdp'

Community Treasure Hunt

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

Start Hunting!