Cody

# Problem 751. Implement simple rotation cypher

Solution 432304

Submitted on 15 Apr 2014 by Joel
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))

positioninalpha = 4 newposition = 14 outStr = n positioninalpha = 15 newposition = 25 outStr = ny positioninalpha = 21 newposition = 31 newposition = 5 outStr = nye positioninalpha = 7 newposition = 17 outStr = nyeq

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

positioninalpha = 20 newposition = 25 outStr = y positioninalpha = 8 newposition = 13 outStr = ym positioninalpha = 5 newposition = 10 outStr = ymj positioninalpha = 17 newposition = 22 outStr = ymjv positioninalpha = 21 newposition = 26 outStr = ymjvz positioninalpha = 9 newposition = 14 outStr = ymjvzn positioninalpha = 3 newposition = 8 outStr = ymjvznh positioninalpha = 11 newposition = 16 outStr = ymjvznhp positioninalpha = 2 newposition = 7 outStr = ymjvznhpg positioninalpha = 18 newposition = 23 outStr = ymjvznhpgw positioninalpha = 15 newposition = 20 outStr = ymjvznhpgwt positioninalpha = 23 newposition = 28 newposition = 2 outStr = ymjvznhpgwtb positioninalpha = 14 newposition = 19 outStr = ymjvznhpgwtbs positioninalpha = 6 newposition = 11 outStr = ymjvznhpgwtbsk positioninalpha = 15 newposition = 20 outStr = ymjvznhpgwtbskt positioninalpha = 24 newposition = 29 newposition = 3 outStr = ymjvznhpgwtbsktc

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

positioninalpha = 20 newposition = 42 newposition = 16 outStr = p positioninalpha = 8 newposition = 30 newposition = 4 outStr = pd positioninalpha = 5 newposition = 27 newposition = 1 outStr = pda positioninalpha = 3 newposition = 25 outStr = pday positioninalpha = 18 newposition = 40 newposition = 14 outStr = pdayn positioninalpha = 15 newposition = 37 newposition = 11 outStr = pdaynk positioninalpha = 23 newposition = 45 newposition = 19 outStr = pdaynks positioninalpha = 6 newposition = 28 newposition = 2 outStr = pdaynksb positioninalpha = 12 newposition = 34 newposition = 8 outStr = pdaynksbh positioninalpha = 9 newposition = 31 newposition = 5 outStr = pdaynksbhe positioninalpha = 5 newposition = 27 newposition = 1 outStr = pdaynksbhea positioninalpha = 19 newposition = 41 newposition = 15 outStr = pdaynksbheao positioninalpha = 1 newposition = 23 outStr = pdaynksbheaow positioninalpha = 20 newposition = 42 newposition = 16 outStr = pdaynksbheaowp positioninalpha = 13 newposition = 35 newposition = 9 outStr = pdaynksbheaowpi positioninalpha = 9 newposition = 31 newposition = 5 outStr = pdaynksbheaowpie positioninalpha = 4 newposition = 26 outStr = pdaynksbheaowpiez positioninalpha = 14 newposition = 36 newposition = 10 outStr = pdaynksbheaowpiezj positioninalpha = 9 newposition = 31 newposition = 5 outStr = pdaynksbheaowpiezje positioninalpha = 7 newposition = 29 newposition = 3 outStr = pdaynksbheaowpiezjec positioninalpha = 8 newposition = 30 newposition = 4 outStr = pdaynksbheaowpiezjecd positioninalpha = 20 newposition = 42 newposition = 16 outStr = pdaynksbheaowpiezjecdp