Cody

Problem 11. Back and Forth Rows

Solution 2626942

Submitted on 29 Jun 2020 by Ali Musani
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
n = 4; a = [ 1 2 3 4; 8 7 6 5; 9 10 11 12; 16 15 14 13]; assert(isequal(a,back_and_forth(n)));

a = 1 b = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 2 b = 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 3 b = 1 2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 4 b = 1 2 3 4 1 1 1 1 1 1 1 1 1 1 1 1 a = 5 b = 1 2 3 4 1 1 1 5 1 1 1 1 1 1 1 1 a = 6 b = 1 2 3 4 1 1 6 5 1 1 1 1 1 1 1 1 a = 7 b = 1 2 3 4 1 7 6 5 1 1 1 1 1 1 1 1 a = 8 b = 1 2 3 4 8 7 6 5 1 1 1 1 1 1 1 1 a = 9 b = 1 2 3 4 8 7 6 5 9 1 1 1 1 1 1 1 a = 10 b = 1 2 3 4 8 7 6 5 9 10 1 1 1 1 1 1 a = 11 b = 1 2 3 4 8 7 6 5 9 10 11 1 1 1 1 1 a = 12 b = 1 2 3 4 8 7 6 5 9 10 11 12 1 1 1 1 a = 13 b = 1 2 3 4 8 7 6 5 9 10 11 12 1 1 1 13 a = 14 b = 1 2 3 4 8 7 6 5 9 10 11 12 1 1 14 13 a = 15 b = 1 2 3 4 8 7 6 5 9 10 11 12 1 15 14 13 a = 16 b = 1 2 3 4 8 7 6 5 9 10 11 12 16 15 14 13 a = 17

2   Pass
n = 5; a = [ 1 2 3 4 5; 10 9 8 7 6; 11 12 13 14 15; 20 19 18 17 16; 21 22 23 24 25]; assert(isequal(a,back_and_forth(n)));

a = 1 b = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 2 b = 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 3 b = 1 2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 4 b = 1 2 3 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 5 b = 1 2 3 4 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 6 b = 1 2 3 4 5 1 1 1 1 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 7 b = 1 2 3 4 5 1 1 1 7 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 8 b = 1 2 3 4 5 1 1 8 7 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 9 b = 1 2 3 4 5 1 9 8 7 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 10 b = 1 2 3 4 5 10 9 8 7 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 11 b = 1 2 3 4 5 10 9 8 7 6 11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 12 b = 1 2 3 4 5 10 9 8 7 6 11 12 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 13 b = 1 2 3 4 5 10 9 8 7 6 11 12 13 1 1 1 1 1 1 1 1 1 1 1 1 a = 14 b = 1 2 3 4 5 10 9 8 7 6 11 12 13 14 1 1 1 1 1 1 1 1 1 1 1 a = 15 b = 1 2 3 4 5 10 9 8 7 6 11 12 13 14 15 1 1 1 1 1 1 1 1 1 1 a = 16 b = 1 2 3 4 5 10 9 8 7 6 11 12 13 14 15 1 1 1 1 16 1 1 1 1 1 a = 17 b = 1 2 3 4 5 10 9 8 7 6 11 12 13 14 15 1 1 1 17 16 1 1 1 1 1 a = 18 b = 1 2 3 4 5 10 9 8 7 6 11 12 13 14 15 1 1 18 17 16 1 1 1 1 1 a = 19 b = 1 2 3 4 5 10 9 8 7 6 11 12 13 14 15 1 19 18 17 16 1 1 1 1 1 a = 20 b = 1 2 3 4 5 10 9 8 7 6 11 12 13 14 15 20 19 18 17 16 1 1 1 1 1 a = 21 b = 1 2 3 4 5 10 9 8 7 6 11 12 13 14 15 20 19 18 17 16 21 1 1 1 1 a = 22 b = 1 2 3 4 5 10 9 8 7 6 11 12 13 14 15 20 19 18 17 16 21 22 1 1 1 a = 23 b = 1 2 3 4 5 10 9 8 7 6 11 12 13 14 15 20 19 18 17 16 21 22 23 1 1 a = 24 b = 1 2 3 4 5 10 9 8 7 6 11 12 13 14 15 20 19 18 17 16 21 22 23 24 1 a = 25 b = 1 2 3 4 5 10 9 8 7 6 11 12 13 14 15 20 19 18 17 16 21 22 23 24 25 a = 26

Suggested Problems

More from this Author95

Community Treasure Hunt

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

Start Hunting!