Cody

Solution 1608362

Submitted on 13 Aug 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   Pass
x = 1:5; for spatula = sort_pancakes(x) x(1:spatula) = flip(x(1:spatula)); end assert(issorted(x))

2   Pass
x = [6 4 2 5 3 1]; for spatula = sort_pancakes(x) x(1:spatula) = flip(x(1:spatula)); end assert(issorted(x))

r = 6 s = 1 3 5 2 4 6 r = 5 s = 4 2 5 3 1 r = 4 s = 3 5 2 4 1 r = 4 s = 4 2 5 3 1 r = 5 s = 1 3 5 2 4 r = 2 s = 3 1 5 2 4 r = 3 s = 5 1 3 2 4 r = 2 s = 1 5 3 2 4 r = 2 s = 5 1 3 2 4 r = 5 s = 4 2 3 1 5 r = 4 s = 1 3 2 4 r = 1 s = 1 3 2 r = 2 s = 3 1 2 r = 3 s = 2 1 3 r = 2 s = 1 2

3   Fail
x = randperm(12); for spatula = sort_pancakes(x) x(1:spatula) = flip(x(1:spatula)); end assert(issorted(x))

r = 5 s = 9 6 12 7 11 3 5 10 8 1 2 4 r = 7 s = 5 3 11 7 12 6 9 10 8 1 2 4 r = 5 s = 12 7 11 3 5 6 9 10 8 1 2 4 r = 10 s = 1 8 10 9 6 5 3 11 7 12 2 4 r = 6 s = 5 6 9 10 8 1 3 11 7 12 2 4 r = 8 s = 11 3 1 8 10 9 6 5 7 12 2 4 r = 12 s = 4 2 12 7 5 6 9 10 8 1 3 11 r = 12 s = 11 3 1 8 10 9 6 5 7 12 2 4 r = 10 s = 12 7 5 6 9 10 8 1 3 11 2 4 r = 7 s = 8 10 9 6 5 7 12 1 3 11 2 4 r = 2 s = 10 8 9 6 5 7 12 1 3 11 2 4 r = 9 s = 3 1 12 7 5 6 9 8 10 11 2 4 r = 3 s = 12 1 3 7 5 6 9 8 10 11 2 4 r = 10 s = 11 10 8 9 6 5 7 3 1 12 2 4 r = 8 s = 3 7 5 6 9 8 10 11 1 12 2 4 r = 12 s = 4 2 12 1 11 10 8 9 6 5 7 3 r = 8 s = 9 8 10 11 1 12 2 4 6 5 7 3 r = 6 s = 12 1 11 10 8 9 2 4 6 5 7 3 r = 6 s = 9 8 10 11 1 12 2 4 6 5 7 3 r = 7 s = 2 12 1 11 10 8 9 4 6 5 7 3 r = 10 s = 5 6 4 9 8 10 11 1 12 2 7 3 r = 2 s = 6 5 4 9 8 10 11 1 12 2 7 3 r = 1 s = 6 5 4 9 8 10 11 1 12 2 7 3 r = 8 s = 1 11 10 8 9 4 5 6 12 2 7 3 r = 2 s = 11 1 10 8 9 4 5 6 12 2 7 3 r = 5 s = 9 8 10 1 11 4 5 6 12 2 7 3 r = 11 s = 7 2 12 6 5 4 11 1 10 8 9 3 r = 11 s = 9 8 10 1 11 4 5 6 12 2 7 3 r = 10 s = 2 12 6 5 4 11 1 10 8 9 7 3 r = 12 s = 3 7 9 8 10 1 11 4 5 6 12 2 r = 9 s = 5 4 11 1 10 8 9 7 3 6 12 2 r = 2 s = 4 5 11 1 10 8 9 7 3 6 12 2 r = 4 s = 1 11 5 4 10 8 9 7 3 6 12 2 r = 4 s = 4 5 11 1 10 8 9 7 3 6 12 2 r = 12 s = 2 12 6 3 7 9 8 10 1 11 5 4 r = 2 s = 12 2 6 3 7 9 8 10 1 11 5 4 r = 3 s = 6 2 12 3 7 9 8 10 1 11 5 4 r = 8 s = 10 8 9 7 3 12 2 6 1 11 5 4 r = 9 s = 1 6 2 12 3 7 9 8 10 11 5 4 r = 9 s = 10 8 9 7 3 12 2 6 1 11 5 4 r = 3 s = 9 8 10 7 3 12 2 6 1 11 5 4 r = 11 s = 5 11 1 6 2 12 3 7 10 8 9 4 r = 7 s = 3 12 2 6 1 11 5 7 10 8 9 4 r = 6 s = 11 1 6 2 12 3 5 7 10 8 9 4 r = 8 s = 7 5 3 12 2 6 1 11 10 8 9 4 r = 10 s = 8 10 11 1 6 2 12 3 5 7 9 4 r = 2 s = 10 8 11 1 6 2 12 3 5 7 9 4 r = 5 s = 6 1 11 8 10 2 12 3 5 7 9 4 r = 9 s = 5 3 12 2 10 8 11 1 6 7 9 4 r = 1 s = 5 3 12 2 10 8 11 1 6 7 9 4 r = 8 s = 1 11 8 10 2 12 3 5 6 7 9 4 r = 4 s = 10 8 11 1 2 12 3 5 6 7 9 4 r = 9 s = 6 5 3 12 2 1 11 8 10 7 9 4 r = 5 s = 2 12 3 5 6 1 11 8 10 7 9 4 r = 11 s = 9 7 10 8 11 1 6 5 3 12 2 4 r = 5 s = 11 8 10 7 9 1 6 5 3 12 2 4 r = 7 s = 6 1 9 7 10 8 11 5 3 12 2 4 r = 7 s = 11 8 10 7 9 1 6 5 3 12 2 4 r = 8 s = 5 6 1 9 7 10 8 11 3 12 2 4 r = 7 s = 8 10 7 9 1 6 5 11 3 12 2 4 r = 1 s = 8 10 7 9 1 6 5 11 3 12 2 4 r = 8 s = 11 5 6 1 9 7 10 8 3 12 2 4 r = 10 s = 12 3 8 10 7 9 1 6 5 11 2 4 r = 6 s = 9 7 10 8 3 12 1 6 5 11 2 4 r = 12 s = 4 2 11 5 6 1 12 3 8 10 7 9 r = 7 s = 12 1 6 5 11 2 4 3 8 10 7 9 r = 12 s = 9 7 10 8 3 4 2 11 5 6 1 12 r = 2 s = 7 9 10 8 3 4 2 11 5 6 1 r = 10 s = 6 5 11 2 4 3 8 10 9 7 1 r = 6 s = 3 4 2 11 5 6 8 10 9 7 1 r = 5 s = 5 11 2 4 3 6 8 10 9 7 1 r = 7 s = 8 6 3 4 2 11 5 10 9 7 1 r = 11 s = 1 7 9 10 5 11 2 4 3 6 8 r = 8 s = 4 2 11 5 10 9 7 1 3 6 8 r = 11 s = 8 6 3 1 7 9 10 5 11 2 4 r = 5 s = 7 1 3 6 8 9 10 5 11 2 4 r = 4 s = 6 3 1 7 8 9 10 5 11 2 4 r = 5 s = 8 7 1 3 6 9 10 5 11 2 4 r = 2 s = 7 8 1 3 6 9 10 5 11 2 4 r = 5 s = 6 3 1 8 7 9 10 5 11 2 4 r = 1 s = 6 3 1 8 7 9 10 5 11 2 4 r = 1 s = 6 3 1 8 7 9 10 5 11 2 4 r = 1 s = 6 3 1 8 7 9 10 5 11 2 4 r = 11 s = 4 2 11 5 10 9 7 8 1 3 6 r = 9 s = 1 8 7 9 10 5 11 2 4 3 6 r = 9 s = 4 2 11 5 10 9 7 8 1 3 6 r = 4 s = 5 11 2 4 10 9 7 8 1 3 6 r = 1 s = 5 11 2 4 10 9 7 8 1 3 6 r = 7 s = 7 9 10 4 2 11 5 8 1 3 6 r = 4 s = 4 10 9 7 2 11 5 8 1 3 6 r = 9 s = 1 8 5 11 2 7 9 10 4 3 6 r = 8 s = 10 9 7 2 11 5 8 1 4 3 6 r = 7 s = 8 5 11 2 7 9 10 1 4 3 6 r = 5 s = 7 2 11 5 8 9 10 1 4 3 6 r = 8 s = 1 10 9 8 5 11 2 7 4 3 6 r = 4 s = 8 9 10 1 5 11 2 7 4 3 6 r = 4 s = 1 10 9 8 5 11 2 7 4 3 6 r = 4 s = 8 9 10 1 5 11 2 7 4 3 6 r = 9 s = 4 7 2 11 5 1 10 9 8 3 6 r = 5 s = 5 11 2 7 4 1 10 9 8 3 6 r = 4 s = 7 2 11 5 4 1 10 9 8 3 6 r = 8 s = 9 10 1 4 5 11 2 7 8 3 6 r = 3 s = 1 10 9 4 5 11 2 7 8 3 6 r = 1 s = 1 10 9 4 5 11 2 7 8 3 6 r = 4 s = 4 9 10 1 5 11 2 7 8 3 6 r = 1 s = 4 9 10 1 5 11 2 7 8 3 6 r = 9 s = 8 7 2 11 5 1 10 9 4 3 6 r = 7 s = 10 1 5 11 2 7 8 9 4 3 6 r = 1 s = 10 1 5 11 2 7 8 9 4 3 6 r = ...

Assertion failed.

4   Fail
x = randperm(13); for spatula = sort_pancakes(x) x(1:spatula) = flip(x(1:spatula)); end assert(issorted(x))

r = 5 s = 6 4 12 1 9 5 13 3 2 8 10 11 7 r = 5 s = 9 1 12 4 6 5 13 3 2 8 10 11 7 r = 8 s = 3 13 5 6 4 12 1 9 2 8 10 11 7 r = 6 s = 12 4 6 5 13 3 1 9 2 8 10 11 7 r = 12 s = 11 10 8 2 9 1 3 13 5 6 4 12 7 r = 5 s = 9 2 8 10 11 1 3 13 5 6 4 12 7 r = 6 s = 1 11 10 8 2 9 3 13 5 6 4 12 7 r = 3 s = 10 11 1 8 2 9 3 13 5 6 4 12 7 r = 13 s = 7 12 4 6 5 13 3 9 2 8 1 11 10 r = 9 s = 2 9 3 13 5 6 4 12 7 8 1 11 10 r = 7 s = 4 6 5 13 3 9 2 12 7 8 1 11 10 r = 5 s = 3 13 5 6 4 9 2 12 7 8 1 11 10 r = 5 s = 4 6 5 13 3 9 2 12 7 8 1 11 10 r = 12 s = 11 1 8 7 12 2 9 3 13 5 6 4 10 r = 10 s = 5 13 3 9 2 12 7 8 1 11 6 4 10 r = 3 s = 3 13 5 9 2 12 7 8 1 11 6 4 10 r = 4 s = 9 5 13 3 2 12 7 8 1 11 6 4 10 r = 6 s = 12 2 3 13 5 9 7 8 1 11 6 4 10 r = 12 s = 4 6 11 1 8 7 9 5 13 3 2 12 10 r = 12 s = 12 2 3 13 5 9 7 8 1 11 6 4 10 r = 4 s = 13 3 2 12 5 9 7 8 1 11 6 4 10 r = 3 s = 2 3 13 12 5 9 7 8 1 11 6 4 10 r = 2 s = 3 2 13 12 5 9 7 8 1 11 6 4 10 r = 9 s = 1 8 7 9 5 12 13 2 3 11 6 4 10 r = 6 s = 12 5 9 7 8 1 13 2 3 11 6 4 10 r = 13 s = 10 4 6 11 3 2 13 1 8 7 9 5 12 r = 4 s = 11 6 4 10 3 2 13 1 8 7 9 5 12 r = 13 s = 12 5 9 7 8 1 13 2 3 10 4 6 11 r = 11 s = 4 10 3 2 13 1 8 7 9 5 12 6 11 r = 10 s = 5 9 7 8 1 13 2 3 10 4 12 6 11 r = 2 s = 9 5 7 8 1 13 2 3 10 4 12 6 11 r = 2 s = 5 9 7 8 1 13 2 3 10 4 12 6 11 r = 9 s = 10 3 2 13 1 8 7 9 5 4 12 6 11 r = 10 s = 4 5 9 7 8 1 13 2 3 10 12 6 11 r = 5 s = 8 7 9 5 4 1 13 2 3 10 12 6 11 r = 10 s = 10 3 2 13 1 4 5 9 7 8 12 6 11 r = 7 s = 5 4 1 13 2 3 10 9 7 8 12 6 11 r = 7 s = 10 3 2 13 1 4 5 9 7 8 12 6 11 r = 8 s = 9 5 4 1 13 2 3 10 7 8 12 6 11 r = 9 s = 7 10 3 2 13 1 4 5 9 8 12 6 11 r = 8 s = 5 4 1 13 2 3 10 7 9 8 12 6 11 r = 1 s = 5 4 1 13 2 3 10 7 9 8 12 6 11 r = 2 s = 4 5 1 13 2 3 10 7 9 8 12 6 11 r = 12 s = 6 12 8 9 7 10 3 2 13 1 5 4 11 r = 12 s = 4 5 1 13 2 3 10 7 9 8 12 6 11 r = 8 s = 7 10 3 2 13 1 5 4 9 8 12 6 11 r = 11 s = 12 8 9 4 5 1 13 2 3 10 7 6 11 r = 2 s = 8 12 9 4 5 1 13 2 3 10 7 6 11 r = 8 s = 2 13 1 5 4 9 12 8 3 10 7 6 11 r = 3 s = 1 13 2 5 4 9 12 8 3 10 7 6 11 r = 11 s = 7 10 3 8 12 9 4 5 2 13 1 6 11 r = 7 s = 4 9 12 8 3 10 7 5 2 13 1 6 11 r = 7 s = 7 10 3 8 12 9 4 5 2 13 1 6 11 r = 5 s = 12 8 3 10 7 9 4 5 2 13 1 6 11 r = 2 s = 8 12 3 10 7 9 4 5 2 13 1 6 11 r = 13 s = 11 6 1 13 2 5 4 9 7 10 3 12 8 r = 8 s = 9 4 5 2 13 1 6 11 7 10 3 12 8 r = 2 s = 4 9 5 2 13 1 6 11 7 10 3 12 8 r = 4 s = 2 5 9 4 13 1 6 11 7 10 3 12 8 r = 6 s = 1 13 4 9 5 2 6 11 7 10 3 12 8 r = 13 s = 8 12 3 10 7 11 6 2 5 9 4 13 1 r = 5 s = 7 10 3 12 8 11 6 2 5 9 4 13 1 r = 13 s = 1 13 4 9 5 2 6 11 8 12 3 10 7 r = 6 s = 2 5 9 4 13 1 6 11 8 12 3 10 7 r = 9 s = 8 11 6 1 13 4 9 5 2 12 3 10 7 r = 8 s = 5 9 4 13 1 6 11 8 2 12 3 10 7 r = 5 s = 1 13 4 9 5 6 11 8 2 12 3 10 7 r = 1 s = 1 13 4 9 5 6 11 8 2 12 3 10 7 r = 13 s = 7 10 3 12 2 8 11 6 5 9 4 13 1 r = 1 s = 7 10 3 12 2 8 11 6 5 9 4 13 1 r = 12 s = 13 4 9 5 6 11 8 2 12 3 10 7 1 r = 1 s = 13 4 9 5 6 11 8 2 12 3 10 7 1 r = 2 s = 4 13 9 5 6 11 8 2 12 3 10 7 1 r = 13 s = 1 7 10 3 12 2 8 11 6 5 9 13 4 r = 7 s = 8 2 12 3 10 7 1 11 6 5 9 13 4 r = 9 s = 6 11 1 7 10 3 12 2 8 5 9 13 4 r = 13 s = 4 13 9 5 8 2 12 3 10 7 1 11 6 r = 8 s = 3 12 2 8 5 9 13 4 10 7 1 11 6 r = 9 s = 10 4 13 9 5 8 2 12 3 7 1 11 6 r = 3 s = 13 4 10 9 5 8 2 12 3 7 1 11 6 r = 5 s = 5 9 10 4 13 8 2 12 3 7 1 11 6 r = 5 s = 13 4 10 9 5 8 2 12 3 7 1 11 6 r = 13 s = 6 11 1 7 3 12 2 8 5 9 10 4 13 r = 3 s = 1 11 6 7 3 12 2 8 5 9 10 4 r = 12 s = 4 10 9 5 8 2 12 3 7 6 11 1 r = 12 s = 1 11 6 7 3 12 2 8 5 9 10 4 r = 8 s = 8 2 12 3 7 6 11 1 5 9 10 4 r = 10 s = 9 5 1 11 6 7 3 12 2 8 10 4 r = 5 s = 6 11 1 5 9 7 3 12 2 8 10 4 r = 8 s = 12 3 7 9 5 1 11 6 2 8 10 4 r = 3 s = 7 3 12 9 5 1 11 6 2 8 10 4 r = 7 s = 11 1 5 9 12 3 7 6 2 8 10 4 r = 9 s = 2 6 7 3 12 9 5 1 11 8 10 4 r = 3 s = 7 6 2 3 12 9 5 1 11 8 10 4 r = 2 s = 6 7 2 3 12 9 5 1 11 8 10 4 r = 1 s = 6 7 2 3 12 9 5 1 11 8 10 4 r = 8 s = 1 5 9 12 3 2 7 6 11 8 10 4 r = 1 s = 1 5 9 12 3 2 7 6 11 8 10 4 r = 2 s = 5 1 9 12 3 2 7 6 11 8 10 4 r = 1 s = 5 1 9 12 3 2 7 6 11 8 10 4 r = 1 s = 5 1 9 12 3 2 7 6 11 8 10 4 r = ...

Assertion failed.

5   Fail
for k = 1:20 x = randperm(k); for spatula = sort_pancakes(x) x(1:spatula) = flip(x(1:spatula)); end assert(issorted(x)) end

Assertion failed.