Cody

# Problem 42494. Which permutation is it?

Solution 2055972

Submitted on 12 Dec 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; y_correct = 1; assert(isequal(whichone(x),y_correct))

Undefined function 'kthperm' for input arguments of type 'double'. Error in whichone (line 6) kthP = kthperm(noOfEle,y); Error in Test1 (line 3) assert(isequal(whichone(x),y_correct))

2   Fail
x = 1:randi(10); y_correct = 1; assert(isequal(whichone(x),y_correct))

Undefined function 'kthperm' for input arguments of type 'double'. Error in whichone (line 6) kthP = kthperm(noOfEle,y); Error in Test2 (line 3) assert(isequal(whichone(x),y_correct))

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

Undefined function 'kthperm' for input arguments of type 'double'. Error in whichone (line 6) kthP = kthperm(noOfEle,y); Error in Test3 (line 3) assert(isequal(whichone(x),y_correct))

4   Fail
x = [1 3 2 4:10]; y_correct = 3; assert(isequal(whichone(x),y_correct))

Undefined function 'kthperm' for input arguments of type 'double'. Error in whichone (line 6) kthP = kthperm(noOfEle,y); Error in Test4 (line 3) assert(isequal(whichone(x),y_correct))

5   Fail
x = [4 3 2 1]; y_correct = 24; assert(isequal(whichone(x),y_correct))

Undefined function 'kthperm' for input arguments of type 'double'. Error in whichone (line 6) kthP = kthperm(noOfEle,y); Error in Test5 (line 3) assert(isequal(whichone(x),y_correct))

6   Fail
x = [4 3 2 1 5 6 7]; y_correct = 24; assert(isequal(whichone(x),y_correct))

Undefined function 'kthperm' for input arguments of type 'double'. Error in whichone (line 6) kthP = kthperm(noOfEle,y); Error in Test6 (line 3) assert(isequal(whichone(x),y_correct))

7   Fail
x = 10:-1:1; y_correct = prod(x); assert(isequal(whichone(x),y_correct))

Undefined function 'kthperm' for input arguments of type 'double'. Error in whichone (line 6) kthP = kthperm(noOfEle,y); Error in Test7 (line 3) assert(isequal(whichone(x),y_correct))

8   Fail
x = 10:-1:1; y_correct = prod(x); assert(isequal(whichone(x),y_correct))

Undefined function 'kthperm' for input arguments of type 'double'. Error in whichone (line 6) kthP = kthperm(noOfEle,y); Error in Test8 (line 3) assert(isequal(whichone(x),y_correct))

9   Fail
x = [6 3 5 1 2 4]; y_correct = 677; assert(isequal(whichone(x),y_correct));

Undefined function 'kthperm' for input arguments of type 'double'. Error in whichone (line 6) kthP = kthperm(noOfEle,y); Error in Test9 (line 3) assert(isequal(whichone(x),y_correct));

10   Fail
for k = 6:15 r = randperm(k); x1 = [r k+1:k+randi(7)]; x2 = [fliplr(r) k+1:k+randi(7)]; assert(isequal(whichone(x1)+whichone(x2)-1,factorial(k))) end

Undefined function 'kthperm' for input arguments of type 'double'. Error in whichone (line 6) kthP = kthperm(noOfEle,y); Error in Test10 (line 5) assert(isequal(whichone(x1)+whichone(x2)-1,factorial(k)))