Cody

# Problem 43079. Check if two matrices are permutations of each other

Solution 1150271

Submitted on 30 Mar 2017 by H M Dipu Kabir
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 2 3; 4 5 6; 7 8 9] y = [3 5 6; 7 1 2; 4 9 8] isPerm = true; assert(isequal(isPermute(x,y),isPerm))

x = 1 2 3 4 5 6 7 8 9 y = 3 5 6 7 1 2 4 9 8 x = 1 4 7 2 5 8 3 6 9 y = 3 7 4 5 1 9 6 2 8 y = 1 2 3 4 5 6 7 8 9

2   Pass
x = [1 2; 4 5; 7 8]; y = x'; isPerm = true; assert(isequal(isPermute(x,y),isPerm))

x = 1 4 7 2 5 8 y = 1 2 4 5 7 8 y = 1 2 4 5 7 8

3   Pass
x = 1:50; y = randperm(50); isPerm = true; assert(isequal(isPermute(x,y),isPerm))

x = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Columns 30 through 50 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 y = Columns 1 through 29 16 48 24 1 44 15 5 40 12 4 39 42 45 3 26 37 19 7 13 10 33 38 20 6 27 18 30 47 28 Columns 30 through 50 2 9 43 50 21 29 8 17 46 14 41 49 31 11 35 25 36 32 34 22 23 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Columns 30 through 50 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

4   Pass
x = 2:51; y = randperm(50); isPerm = false; assert(isequal(isPermute(x,y),isPerm))

x = Columns 1 through 29 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Columns 30 through 50 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 y = Columns 1 through 29 10 9 27 21 1 33 22 17 7 13 34 40 24 44 42 49 29 18 37 32 11 30 43 46 25 35 5 28 20 Columns 30 through 50 50 48 3 41 47 26 6 23 4 14 15 2 16 38 19 31 39 45 36 8 12 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Columns 30 through 50 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

5   Pass
x = [1 2 3; 4 5 6; 7 8 9] y = [3 5; 7 1; 4 9] isPerm = false; assert(isequal(isPermute(x,y),isPerm))

x = 1 2 3 4 5 6 7 8 9 y = 3 5 7 1 4 9 x = 1 4 7 2 5 8 3 6 9 y = 3 7 4 5 1 9 y = 1 3 4 5 7 9