Cody

# Problem 43047. Wrap-around effect

Solution 2886728

Submitted on 28 Aug 2020
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   Fail
x = 1; pos = 1; y_correct = 1; assert(isequal(wrapAround(x,pos),y_correct))

Index in position 1 is invalid. Array indices must be positive integers or logical values. Error in wrapAround (line 2) y = x(pos-1,numel(x))+1; Error in Test1 (line 4) assert(isequal(wrapAround(x,pos),y_correct))

2   Fail
x = [1 2 3 4 5]; pos = 99; y_correct = 4; assert(isequal(wrapAround(x,pos),y_correct))

Index in position 1 exceeds array bounds (must not exceed 1). Error in wrapAround (line 2) y = x(pos-1,numel(x))+1; Error in Test2 (line 4) assert(isequal(wrapAround(x,pos),y_correct))

3   Fail
x = 7:101; pos = 909; y_correct = 60; assert(isequal(wrapAround(x,pos),y_correct))

Index in position 1 exceeds array bounds (must not exceed 1). Error in wrapAround (line 2) y = x(pos-1,numel(x))+1; Error in Test3 (line 4) assert(isequal(wrapAround(x,pos),y_correct))

4   Fail
x = 5:5:100; pos = 101; y_correct = 5; assert(isequal(wrapAround(x,pos),y_correct))

Index in position 1 exceeds array bounds (must not exceed 1). Error in wrapAround (line 2) y = x(pos-1,numel(x))+1; Error in Test4 (line 4) assert(isequal(wrapAround(x,pos),y_correct))

5   Fail
x = -17:3:99; pos = 1001; y_correct = 58; assert(isequal(wrapAround(x,pos),y_correct))

Index in position 1 exceeds array bounds (must not exceed 1). Error in wrapAround (line 2) y = x(pos-1,numel(x))+1; Error in Test5 (line 4) assert(isequal(wrapAround(x,pos),y_correct))

6   Fail
x = 1:3:777; pos = 789; y_correct = 34; assert(isequal(wrapAround(x,pos),y_correct))

Index in position 1 exceeds array bounds (must not exceed 1). Error in wrapAround (line 2) y = x(pos-1,numel(x))+1; Error in Test6 (line 4) assert(isequal(wrapAround(x,pos),y_correct))

### Community Treasure Hunt

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

Start Hunting!