Cody

Problem 42495. N-th permutation.

Solution 1669971

Submitted on 9 Nov 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   Fail
x = 1; y_correct = []; assert(isempty(whichperm(x)))

4 3 2 1 4 3 1 2 4 2 3 1 4 2 1 3 4 1 3 2 4 1 2 3 3 4 2 1 3 4 1 2 3 2 4 1 3 2 1 4 3 1 4 2 3 1 2 4 2 4 3 1 2 4 1 3 2 3 4 1 2 3 1 4 2 1 4 3 2 1 3 4 1 4 3 2 1 4 2 3 1 3 4 2 1 3 2 4 1 2 4 3 1 2 3 4

Output argument "P" (and maybe others) not assigned during call to "whichperm". Error in Test1 (line 3) assert(isempty(whichperm(x)))

2   Fail
x = 2; y_correct = 2; assert(isequal(whichperm(x),y_correct))

4 3 2 1 4 3 1 2 4 2 3 1 4 2 1 3 4 1 3 2 4 1 2 3 3 4 2 1 3 4 1 2 3 2 4 1 3 2 1 4 3 1 4 2 3 1 2 4 2 4 3 1 2 4 1 3 2 3 4 1 2 3 1 4 2 1 4 3 2 1 3 4 1 4 3 2 1 4 2 3 1 3 4 2 1 3 2 4 1 2 4 3 1 2 3 4

Output argument "P" (and maybe others) not assigned during call to "whichperm". Error in Test2 (line 3) assert(isequal(whichperm(x),y_correct))

3   Fail
x = 3; y_correct = [1 3]; assert(isequal(whichperm(x),y_correct))

4 3 2 1 4 3 1 2 4 2 3 1 4 2 1 3 4 1 3 2 4 1 2 3 3 4 2 1 3 4 1 2 3 2 4 1 3 2 1 4 3 1 4 2 3 1 2 4 2 4 3 1 2 4 1 3 2 3 4 1 2 3 1 4 2 1 4 3 2 1 3 4 1 4 3 2 1 4 2 3 1 3 4 2 1 3 2 4 1 2 4 3 1 2 3 4

Output argument "P" (and maybe others) not assigned during call to "whichperm". Error in Test3 (line 3) assert(isequal(whichperm(x),y_correct))

4   Fail
x = 4; y_correct = [2 3]; assert(isequal(whichperm(x),y_correct))

4 3 2 1 4 3 1 2 4 2 3 1 4 2 1 3 4 1 3 2 4 1 2 3 3 4 2 1 3 4 1 2 3 2 4 1 3 2 1 4 3 1 4 2 3 1 2 4 2 4 3 1 2 4 1 3 2 3 4 1 2 3 1 4 2 1 4 3 2 1 3 4 1 4 3 2 1 4 2 3 1 3 4 2 1 3 2 4 1 2 4 3 1 2 3 4

Output argument "P" (and maybe others) not assigned during call to "whichperm". Error in Test4 (line 3) assert(isequal(whichperm(x),y_correct))

5   Fail
x = 5; y_correct = 3; assert(isequal(whichperm(x),y_correct))

4 3 2 1 4 3 1 2 4 2 3 1 4 2 1 3 4 1 3 2 4 1 2 3 3 4 2 1 3 4 1 2 3 2 4 1 3 2 1 4 3 1 4 2 3 1 2 4 2 4 3 1 2 4 1 3 2 3 4 1 2 3 1 4 2 1 4 3 2 1 3 4 1 4 3 2 1 4 2 3 1 3 4 2 1 3 2 4 1 2 4 3 1 2 3 4

Output argument "P" (and maybe others) not assigned during call to "whichperm". Error in Test5 (line 3) assert(isequal(whichperm(x),y_correct))

6   Fail
x = 10; y_correct = [2 3 4]; assert(isequal(whichperm(x),y_correct))

4 3 2 1 4 3 1 2 4 2 3 1 4 2 1 3 4 1 3 2 4 1 2 3 3 4 2 1 3 4 1 2 3 2 4 1 3 2 1 4 3 1 4 2 3 1 2 4 2 4 3 1 2 4 1 3 2 3 4 1 2 3 1 4 2 1 4 3 2 1 3 4 1 4 3 2 1 4 2 3 1 3 4 2 1 3 2 4 1 2 4 3 1 2 3 4

Output argument "P" (and maybe others) not assigned during call to "whichperm". Error in Test6 (line 3) assert(isequal(whichperm(x),y_correct))

7   Fail
x = 9; y_correct = [1 3 4]; assert(isequal(whichperm(x),y_correct))

4 3 2 1 4 3 1 2 4 2 3 1 4 2 1 3 4 1 3 2 4 1 2 3 3 4 2 1 3 4 1 2 3 2 4 1 3 2 1 4 3 1 4 2 3 1 2 4 2 4 3 1 2 4 1 3 2 3 4 1 2 3 1 4 2 1 4 3 2 1 3 4 1 4 3 2 1 4 2 3 1 3 4 2 1 3 2 4 1 2 4 3 1 2 3 4

Output argument "P" (and maybe others) not assigned during call to "whichperm". Error in Test7 (line 3) assert(isequal(whichperm(x),y_correct))

8   Fail
x = 323; y_correct = [3 5 1 6 4]; assert(isequal(whichperm(x),y_correct))

4 3 2 1 4 3 1 2 4 2 3 1 4 2 1 3 4 1 3 2 4 1 2 3 3 4 2 1 3 4 1 2 3 2 4 1 3 2 1 4 3 1 4 2 3 1 2 4 2 4 3 1 2 4 1 3 2 3 4 1 2 3 1 4 2 1 4 3 2 1 3 4 1 4 3 2 1 4 2 3 1 3 4 2 1 3 2 4 1 2 4 3 1 2 3 4

Output argument "P" (and maybe others) not assigned during call to "whichperm". Error in Test8 (line 3) assert(isequal(whichperm(x),y_correct))

9   Fail
x = 2015; y_correct = [4 6 5 3 7]; assert(isequal(whichperm(x),y_correct))

4 3 2 1 4 3 1 2 4 2 3 1 4 2 1 3 4 1 3 2 4 1 2 3 3 4 2 1 3 4 1 2 3 2 4 1 3 2 1 4 3 1 4 2 3 1 2 4 2 4 3 1 2 4 1 3 2 3 4 1 2 3 1 4 2 1 4 3 2 1 3 4 1 4 3 2 1 4 2 3 1 3 4 2 1 3 2 4 1 2 4 3 1 2 3 4

Output argument "P" (and maybe others) not assigned during call to "whichperm". Error in Test9 (line 3) assert(isequal(whichperm(x),y_correct))

10   Fail
x = 2016; y_correct = [4 6 5 3 7 2]; assert(isequal(whichperm(x),y_correct))

4 3 2 1 4 3 1 2 4 2 3 1 4 2 1 3 4 1 3 2 4 1 2 3 3 4 2 1 3 4 1 2 3 2 4 1 3 2 1 4 3 1 4 2 3 1 2 4 2 4 3 1 2 4 1 3 2 3 4 1 2 3 1 4 2 1 4 3 2 1 3 4 1 4 3 2 1 4 2 3 1 3 4 2 1 3 2 4 1 2 4 3 1 2 3 4

Output argument "P" (and maybe others) not assigned during call to "whichperm". Error in Test10 (line 3) assert(isequal(whichperm(x),y_correct))

11   Fail
x = 1234567890; y_correct = [11 7 3 5 6 12 4 2 8 10 13 9]; assert(isequal(whichperm(x),y_correct))

4 3 2 1 4 3 1 2 4 2 3 1 4 2 1 3 4 1 3 2 4 1 2 3 3 4 2 1 3 4 1 2 3 2 4 1 3 2 1 4 3 1 4 2 3 1 2 4 2 4 3 1 2 4 1 3 2 3 4 1 2 3 1 4 2 1 4 3 2 1 3 4 1 4 3 2 1 4 2 3 1 3 4 2 1 3 2 4 1 2 4 3 1 2 3 4

Output argument "P" (and maybe others) not assigned during call to "whichperm". Error in Test11 (line 3) assert(isequal(whichperm(x),y_correct))

12   Fail
x = 720; y_correct = [6 5 4 3 2]; assert(isequal(whichperm(x),y_correct))

4 3 2 1 4 3 1 2 4 2 3 1 4 2 1 3 4 1 3 2 4 1 2 3 3 4 2 1 3 4 1 2 3 2 4 1 3 2 1 4 3 1 4 2 3 1 2 4 2 4 3 1 2 4 1 3 2 3 4 1 2 3 1 4 2 1 4 3 2 1 3 4 1 4 3 2 1 4 2 3 1 3 4 2 1 3 2 4 1 2 4 3 1 2 3 4

Output argument "P" (and maybe others) not assigned during call to "whichperm". Error in Test12 (line 3) assert(isequal(whichperm(x),y_correct))

13   Fail
x = 721; y_correct = [1 2 3 4 5 7]; assert(isequal(whichperm(x),y_correct))

4 3 2 1 4 3 1 2 4 2 3 1 4 2 1 3 4 1 3 2 4 1 2 3 3 4 2 1 3 4 1 2 3 2 4 1 3 2 1 4 3 1 4 2 3 1 2 4 2 4 3 1 2 4 1 3 2 3 4 1 2 3 1 4 2 1 4 3 2 1 3 4 1 4 3 2 1 4 2 3 1 3 4 2 1 3 2 4 1 2 4 3 1 2 3 4

Output argument "P" (and maybe others) not assigned during call to "whichperm". Error in Test13 (line 3) assert(isequal(whichperm(x),y_correct))

14   Fail
x = 13; y_correct = [1 4]; assert(isequal(whichperm(x),y_correct))

4 3 2 1 4 3 1 2 4 2 3 1 4 2 1 3 4 1 3 2 4 1 2 3 3 4 2 1 3 4 1 2 3 2 4 1 3 2 1 4 3 1 4 2 3 1 2 4 2 4 3 1 2 4 1 3 2 3 4 1 2 3 1 4 2 1 4 3 2 1 3 4 1 4 3 2 1 4 2 3 1 3 4 2 1 3 2 4 1 2 4 3 1 2 3 4

Output argument "P" (and maybe others) not assigned during call to "whichperm". Error in Test14 (line 3) assert(isequal(whichperm(x),y_correct))

15   Fail
x = 100; y_correct = [5 2 3]; assert(isequal(whichperm(x),y_correct))

4 3 2 1 4 3 1 2 4 2 3 1 4 2 1 3 4 1 3 2 4 1 2 3 3 4 2 1 3 4 1 2 3 2 4 1 3 2 1 4 3 1 4 2 3 1 2 4 2 4 3 1 2 4 1 3 2 3 4 1 2 3 1 4 2 1 4 3 2 1 3 4 1 4 3 2 1 4 2 3 1 3 4 2 1 3 2 4 1 2 4 3 1 2 3 4

Output argument "P" (and maybe others) not assigned during call to "whichperm". Error in Test15 (line 3) assert(isequal(whichperm(x),y_correct))

16   Fail
x = 100000000; y_correct = [6 2 4 9 10 11 3 5 7 12 8]; assert(isequal(whichperm(x),y_correct))

4 3 2 1 4 3 1 2 4 2 3 1 4 2 1 3 4 1 3 2 4 1 2 3 3 4 2 1 3 4 1 2 3 2 4 1 3 2 1 4 3 1 4 2 3 1 2 4 2 4 3 1 2 4 1 3 2 3 4 1 2 3 1 4 2 1 4 3 2 1 3 4 1 4 3 2 1 4 2 3 1 3 4 2 1 3 2 4 1 2 4 3 1 2 3 4

Output argument "P" (and maybe others) not assigned during call to "whichperm". Error in Test16 (line 3) assert(isequal(whichperm(x),y_correct))

17   Fail
x = 439084801; y_correct = [12]; assert(isequal(whichperm(x),y_correct))

4 3 2 1 4 3 1 2 4 2 3 1 4 2 1 3 4 1 3 2 4 1 2 3 3 4 2 1 3 4 1 2 3 2 4 1 3 2 1 4 3 1 4 2 3 1 2 4 2 4 3 1 2 4 1 3 2 3 4 1 2 3 1 4 2 1 4 3 2 1 3 4 1 4 3 2 1 4 2 3 1 3 4 2 1 3 2 4 1 2 4 3 1 2 3 4

Output argument "P" (and maybe others) not assigned during call to "whichperm". Error in Test17 (line 3) assert(isequal(whichperm(x),y_correct))

18   Fail
x = flintmax; y_correct = [15 12 11 2 1 10 9 4 16 5 18 3 17 14 8 6 7 19]; assert(isequal(whichperm(x),y_correct))

4 3 2 1 4 3 1 2 4 2 3 1 4 2 1 3 4 1 3 2 4 1 2 3 3 4 2 1 3 4 1 2 3 2 4 1 3 2 1 4 3 1 4 2 3 1 2 4 2 4 3 1 2 4 1 3 2 3 4 1 2 3 1 4 2 1 4 3 2 1 3 4 1 4 3 2 1 4 2 3 1 3 4 2 1 3 2 4 1 2 4 3 1 2 3 4

Output argument "P" (and maybe others) not assigned during call to "whichperm". Error in Test18 (line 3) assert(isequal(whichperm(x),y_correct))