Cody

# Problem 42480. Go back n times

Solution 1697681

Submitted on 20 Dec 2018 by HH
• Size: 9
• This is the leading solution.
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
x = [1:6]'; n = 3; y_correct = [1 NaN NaN NaN 2 1 NaN NaN 3 2 1 NaN 4 3 2 1 5 4 3 2 6 5 4 3]; assert(isequalwithequalnans(goNtimes(x,n),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In goNtimes (line 2) In ScoringEngineTestPoint1 (line 9) In solutionTest (line 3)]

2   Pass
x = [17;23;4;10;11]; n = 4; y_correct = [17 NaN NaN NaN NaN 23 17 NaN NaN NaN 4 23 17 NaN NaN 10 4 23 17 NaN 11 10 4 23 17]; assert(isequalwithequalnans(goNtimes(x,n),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In goNtimes (line 2) In ScoringEngineTestPoint2 (line 8) In solutionTest (line 5)]

3   Pass
x = [35;3;31;8;30;4]; n = 1; y_correct = [35 NaN 3 35 31 3 8 31 30 8 4 30]; assert(isequalwithequalnans(goNtimes(x,n),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In goNtimes (line 2) In ScoringEngineTestPoint3 (line 9) In solutionTest (line 7)]

4   Pass
x = [35;3;31;8;30;4]; n = 2; y_correct = [35 NaN NaN 3 35 NaN 31 3 35 8 31 3 30 8 31 4 30 8]; assert(isequalwithequalnans(goNtimes(x,n),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In goNtimes (line 2) In ScoringEngineTestPoint4 (line 9) In solutionTest (line 9)]

5   Pass
x = [30;38;46;5;13;21;22]; n = 4; y_correct = [30 NaN NaN NaN NaN 38 30 NaN NaN NaN 46 38 30 NaN NaN 5 46 38 30 NaN 13 5 46 38 30 21 13 5 46 38 22 21 13 5 46]; assert(isequalwithequalnans(goNtimes(x,n),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In goNtimes (line 2) In ScoringEngineTestPoint5 (line 10) In solutionTest (line 11)]

### Community Treasure Hunt

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

Start Hunting!