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

### Community Treasure Hunt

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

Start Hunting!
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://la.mathworks.com/matlabcentral/cody/problems/11-back-and-forth-rows/solutions/2626942", "fetch_time": 1606244072000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2020-50/segments/1606141176922.14/warc/CC-MAIN-20201124170142-20201124200142-00002.warc.gz", "warc_record_offset": 360623230, "warc_record_length": 17590, "token_count": 2248, "char_count": 2996, "score": 3.8125, "int_score": 4, "crawl": "CC-MAIN-2020-50", "snapshot_type": "latest", "language": "en", "language_score": 0.41251692175865173, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00002-of-00064.parquet"}