Cody

Solution 869798

Submitted on 10 Apr 2016 by William
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))

m = 5 m = 4 m = 3 m = 2

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))

m = 1 m = 3 m = 1 m = 1 m = 1

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

m = 7 m = 7 m = 3 m = 6 m = 5 m = 4 m = 1 m = 4 m = 2 m = 1 m = 2

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

m = 1 m = 6 m = 6 m = 6 m = 3 m = 2 m = 6 m = 5 m = 2 m = 2 m = 2 m = 1

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

m = 1 m = 1 m = 2 m = 1 m = 3 m = 2 m = 2 m = 2 m = 1 m = 2 m = 6 m = 1 m = 3 m = 1 m = 1 m = 2 m = 1 m = 5 m = 1 m = 3 m = 1 m = 6 m = 2 m = 1 m = 4 m = 1 m = 1 m = 1 m = 3 m = 6 m = 2 m = 2 m = 1 m = 3 m = 2 m = 1 m = 7 m = 8 m = 2 m = 6 m = 4 m = 3 m = 2 m = 1 m = 2 m = 3 m = 7 m = 8 m = 5 m = 4 m = 4 m = 2 m = 2 m = 3 m = 2 m = 5 m = 2 m = 9 m = 5 m = 5 m = 7 m = 2 m = 2 m = 3 m = 3 m = 2 m = 4 m = 1 m = 4 m = 7 m = 8 m = 6 m = 4 m = 3 m = 4 m = 3 m = 3 m = 2 m = 11 m = 2 m = 10 m = 9 m = 2 m = 9 m = 7 m = 7 m = 1 m = 2 m = 3 m = 3 m = 2 m = 5 m = 7 m = 7 m = 1 m = 1 m = 9 m = 4 m = 6 m = 1 m = 5 m = 1 m = 4 m = 2 m = 2 m = 8 m = 12 m = 14 m = 12 m = 12 m = 9 m = 5 m = 7 m = 3 m = 4 m = 3 m = 5 m = 1 m = 3 m = 2 m = 7 m = 2 m = 1 m = 4 m = 13 m = 8 m = 7 m = 1 m = 1 m = 8 m = 1 m = 3 m = 4 m = 4 m = 1 m = 1 m = 4 m = 6 m = 9 m = 1 m = 9 m = 3 m = 7 m = 3 m = 5 m = 5 m = 3 m = 7 m = 2 m = 3 m = 3 m = 3 m = 2 m = 10 m = 13 m = 6 m = 2 m = 9 m = 10 m = 4 m = 7 m = 8 m = 4 m = 1 m = 7 m = 2 m = 4 m = 1 m = 2 m = 1 m = 1 m = 8 m = 6 m = 5 m = 9 m = 2 m = 2 m = 8 m = 4 m = 10 m = 2 m = 10 m = 5 m = 1 m = 3 m = 4 m = 4 m = 4 m = 2 m = 2