Cody

Solution 2450439

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

t = 1 5 4 3 2 part1 = 1 part2 = 2 3 4 5 stack = 1 2 3 4 5 y = 1 part1 = 5 4 3 2 1 part2 = 1×0 empty double row vector stack = 5 4 3 2 1 y = 1 5 part1 = 4 5 part2 = 3 2 1 stack = 4 5 3 2 1 y = 1 5 2 part1 = 3 5 4 part2 = 2 1 stack = 3 5 4 2 1 y = 1 5 2 3

Assertion failed.

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

t = 1 6 5 4 3 2 part1 = 1 3 5 2 4 6 part2 = 1×0 empty double row vector stack = 1 3 5 2 4 6 y = 6 part1 = 6 4 2 5 3 1 part2 = 1×0 empty double row vector stack = 6 4 2 5 3 1 y = 6 6 part1 = 5 2 4 6 part2 = 3 1 stack = 5 2 4 6 3 1 y = 6 6 4 part1 = 4 2 5 part2 = 6 3 1 stack = 4 2 5 6 3 1 y = 6 6 4 3 part1 = 3 6 5 2 4 part2 = 1 stack = 3 6 5 2 4 1 y = 6 6 4 3 5

Assertion failed.

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

t = 1 12 11 10 9 8 7 6 5 4 3 2 part1 = 1 8 7 10 2 part2 = 11 3 12 9 6 4 5 stack = 1 8 7 10 2 11 3 12 9 6 4 5 y = 5 part1 = 12 3 11 2 10 7 8 1 part2 = 9 6 4 5 stack = 12 3 11 2 10 7 8 1 9 6 4 5 y = 5 8 part1 = 11 3 12 part2 = 2 10 7 8 1 9 6 4 5 stack = 11 3 12 2 10 7 8 1 9 6 4 5 y = 5 8 3 part1 = 10 2 12 3 11 part2 = 7 8 1 9 6 4 5 stack = 10 2 12 3 11 7 8 1 9 6 4 5 y = 5 8 3 5 part1 = 9 1 8 7 11 3 12 2 10 part2 = 6 4 5 stack = 9 1 8 7 11 3 12 2 10 6 4 5 y = 5 8 3 5 9 part1 = 8 1 9 part2 = 7 11 3 12 2 10 6 4 5 stack = 8 1 9 7 11 3 12 2 10 6 4 5 y = 5 8 3 5 9 3 part1 = 7 9 1 8 part2 = 11 3 12 2 10 6 4 5 stack = 7 9 1 8 11 3 12 2 10 6 4 5 y = 5 8 3 5 9 3 4 part1 = 6 10 2 12 3 11 8 1 9 7 part2 = 4 5 stack = 6 10 2 12 3 11 8 1 9 7 4 5 y = 5 8 3 5 9 3 4 10 part1 = 5 4 7 9 1 8 11 3 12 2 10 6 part2 = 1×0 empty double row vector stack = 5 4 7 9 1 8 11 3 12 2 10 6 y = 5 8 3 5 9 3 4 10 12 part1 = 4 5 part2 = 7 9 1 8 11 3 12 2 10 6 stack = 4 5 7 9 1 8 11 3 12 2 10 6 y = 5 8 3 5 9 3 4 10 12 2 part1 = 3 11 8 1 9 7 5 4 part2 = 12 2 10 6 stack = 3 11 8 1 9 7 5 4 12 2 10 6 y = 5 8 3 5 9 3 4 10 12 2 8

Assertion failed.

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

t = 1 13 12 11 10 9 8 7 6 5 4 3 2 part1 = 1 9 5 4 11 2 8 13 10 3 7 6 part2 = 12 stack = 1 9 5 4 11 2 8 13 10 3 7 6 12 y = 12 part1 = 13 8 2 11 4 5 9 1 part2 = 10 3 7 6 12 stack = 13 8 2 11 4 5 9 1 10 3 7 6 12 y = 12 8 part1 = 12 6 7 3 10 1 9 5 4 11 2 8 13 part2 = 1×0 empty double row vector stack = 12 6 7 3 10 1 9 5 4 11 2 8 13 y = 12 8 13 part1 = 11 4 5 9 1 10 3 7 6 12 part2 = 2 8 13 stack = 11 4 5 9 1 10 3 7 6 12 2 8 13 y = 12 8 13 10 part1 = 10 1 9 5 4 11 part2 = 3 7 6 12 2 8 13 stack = 10 1 9 5 4 11 3 7 6 12 2 8 13 y = 12 8 13 10 6 part1 = 9 1 10 part2 = 5 4 11 3 7 6 12 2 8 13 stack = 9 1 10 5 4 11 3 7 6 12 2 8 13 y = 12 8 13 10 6 3 part1 = 8 2 12 6 7 3 11 4 5 10 1 9 part2 = 13 stack = 8 2 12 6 7 3 11 4 5 10 1 9 13 y = 12 8 13 10 6 3 12 part1 = 7 6 12 2 8 part2 = 3 11 4 5 10 1 9 13 stack = 7 6 12 2 8 3 11 4 5 10 1 9 13 y = 12 8 13 10 6 3 12 5 part1 = 6 7 part2 = 12 2 8 3 11 4 5 10 1 9 13 stack = 6 7 12 2 8 3 11 4 5 10 1 9 13 y = 12 8 13 10 6 3 12 5 2 part1 = 5 4 11 3 8 2 12 7 6 part2 = 10 1 9 13 stack = 5 4 11 3 8 2 12 7 6 10 1 9 13 y = 12 8 13 10 6 3 12 5 2 9 part1 = 4 5 part2 = 11 3 8 2 12 7 6 10 1 9 13 stack = 4 5 11 3 8 2 12 7 6 10 1 9 13 y = 12 8 13 10 6 3 12 5 2 9 2 part1 = 3 11 5 4 part2 = 8 2 12 7 6 10 1 9 13 stack = 3 11 5 4 8 2 12 7 6 10 1 9 13 y = 12 8 13 10 6 3 12 5 2 9 2 4

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

t = 1 t = 1 2 part1 = 1 2 part2 = 1×0 empty double row vector stack = 1 2 y = 2 t = 1 3 2 part1 = 1 part2 = 2 3 stack = 1 2 3 y = 1 part1 = 3 2 1 part2 = 1×0 empty double row vector stack = 3 2 1 y = 1 3

Assertion failed.

Suggested Problems

More from this Author41