Cody

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

Solution 1987961

Submitted on 23 Oct 2019
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   Fail
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 isPerm = 1 2 3 4 5 6 7 8 9

Assertion failed.

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

isPerm = 1 2 4 5 7 8

Assertion failed.

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

isPerm = Columns 1 through 30 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 30 Columns 31 through 50 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

Assertion failed.

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

isPerm = Columns 1 through 30 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 31 Columns 31 through 49 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

Assertion failed.

5   Fail
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 isPerm = 1 3 4 5 7 9

Assertion failed.