Cody

# Problem 43682. Pairwise column flip

Solution 1570811

Submitted on 28 Jun 2018
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; y_correct = 1; assert(isequal(flip_columns(x),y_correct))

cols = 1 key = Columns 1 through 30 2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 Columns 31 through 60 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 50 49 52 51 54 53 56 55 58 57 60 59 Columns 61 through 90 62 61 64 63 66 65 68 67 70 69 72 71 74 73 76 75 78 77 80 79 82 81 84 83 86 85 88 87 90 89 Columns 91 through 100 92 91 94 93 96 95 98 97 100 99 key = 2 key = 1 y = 1

2   Pass
x = 1:5; y_correct = [2 1 4 3 5]; assert(isequal(flip_columns(x),y_correct))

cols = 5 key = Columns 1 through 30 2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 Columns 31 through 60 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 50 49 52 51 54 53 56 55 58 57 60 59 Columns 61 through 90 62 61 64 63 66 65 68 67 70 69 72 71 74 73 76 75 78 77 80 79 82 81 84 83 86 85 88 87 90 89 Columns 91 through 100 92 91 94 93 96 95 98 97 100 99 key = 2 1 4 3 6 key = 2 1 4 3 5 y = 2 1 4 3 5

3   Pass
x = [1 2 3 4 5]; y_correct = [2 1 4 3 5]; assert(isequal(flip_columns(x),y_correct))

cols = 5 key = Columns 1 through 30 2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 Columns 31 through 60 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 50 49 52 51 54 53 56 55 58 57 60 59 Columns 61 through 90 62 61 64 63 66 65 68 67 70 69 72 71 74 73 76 75 78 77 80 79 82 81 84 83 86 85 88 87 90 89 Columns 91 through 100 92 91 94 93 96 95 98 97 100 99 key = 2 1 4 3 6 key = 2 1 4 3 5 y = 2 1 4 3 5

4   Fail
x = eye(4); y_correct = [0 1 0 0; 1 0 0 0; 0 0 0 1; 0 0 1 0]; assert(isequal(flip_columns(x),y_correct))

cols = 4 key = Columns 1 through 30 2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 Columns 31 through 60 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 50 49 52 51 54 53 56 55 58 57 60 59 Columns 61 through 90 62 61 64 63 66 65 68 67 70 69 72 71 74 73 76 75 78 77 80 79 82 81 84 83 86 85 88 87 90 89 Columns 91 through 100 92 91 94 93 96 95 98 97 100 99 key = 2 1 4 3 y = 0 1 0 0

Assertion failed.

5   Fail
x = magic(5); y_correct = [24 17 8 1 15; ... 5 23 14 7 16; ... 6 4 20 13 22; ... 12 10 21 19 3; ... 18 11 2 25 9]; assert(isequal(flip_columns(x),y_correct))

cols = 5 key = Columns 1 through 30 2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 Columns 31 through 60 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 50 49 52 51 54 53 56 55 58 57 60 59 Columns 61 through 90 62 61 64 63 66 65 68 67 70 69 72 71 74 73 76 75 78 77 80 79 82 81 84 83 86 85 88 87 90 89 Columns 91 through 100 92 91 94 93 96 95 98 97 100 99 key = 2 1 4 3 6 key = 2 1 4 3 5 y = 23 17 10 4 11

Assertion failed.