Cody

# Problem 42494. Which permutation is it?

Solution 711672

Submitted on 7 Aug 2015 by Jan Orwat
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(whichone(x),y_correct))

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

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

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

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

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

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

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

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

10   Pass
%% 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

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!