Cody

Solution 1608356

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

Array indices must be positive integers or logical values. Error in sort_pancakes (line 3) while s(end)<numel(s) Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in Test1 (line 2) for spatula = sort_pancakes(x)

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

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

Array indices must be positive integers or logical values. Error in sort_pancakes (line 3) while s(end)<numel(s) Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in Test2 (line 2) for spatula = sort_pancakes(x)

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

r = 4 s = 12 5 8 3 7 2 4 6 9 1 11 10 r = 6 s = 2 7 3 8 5 12 4 6 9 1 11 10 r = 8 s = 6 4 12 5 8 3 7 2 9 1 11 10 r = 6 s = 3 8 5 12 4 6 7 2 9 1 11 10 r = 9 s = 9 2 7 6 4 12 5 8 3 1 11 10 r = 12 s = 10 11 1 3 8 5 12 4 6 7 2 9 r = 3 s = 1 11 10 3 8 5 12 4 6 7 2 9 r = 7 s = 12 5 8 3 10 11 1 4 6 7 2 9 r = 10 s = 7 6 4 1 11 10 3 8 5 12 2 9 r = 8 s = 8 3 10 11 1 4 6 7 5 12 2 9 r = 11 s = 2 12 5 7 6 4 1 11 10 3 8 9 r = 1 s = 2 12 5 7 6 4 1 11 10 3 8 9 r = 1 s = 2 12 5 7 6 4 1 11 10 3 8 9 r = 4 s = 7 5 12 2 6 4 1 11 10 3 8 9 r = 1 s = 7 5 12 2 6 4 1 11 10 3 8 9 r = 6 s = 4 6 2 12 5 7 1 11 10 3 8 9 r = 2 s = 6 4 2 12 5 7 1 11 10 3 8 9 r = 3 s = 2 4 6 12 5 7 1 11 10 3 8 9 r = 7 s = 1 7 5 12 6 4 2 11 10 3 8 9 r = 8 s = 11 2 4 6 12 5 7 1 10 3 8 9 r = 3 s = 4 2 11 6 12 5 7 1 10 3 8 9 r = 3 s = 11 2 4 6 12 5 7 1 10 3 8 9 r = 4 s = 6 4 2 11 12 5 7 1 10 3 8 9 r = 3 s = 2 4 6 11 12 5 7 1 10 3 8 9 r = 5 s = 12 11 6 4 2 5 7 1 10 3 8 9 r = 4 s = 4 6 11 12 2 5 7 1 10 3 8 9 r = 8 s = 1 7 5 2 12 11 6 4 10 3 8 9 r = 2 s = 7 1 5 2 12 11 6 4 10 3 8 9 r = 3 s = 5 1 7 2 12 11 6 4 10 3 8 9 r = 9 s = 10 4 6 11 12 2 7 1 5 3 8 9 r = 4 s = 11 6 4 10 12 2 7 1 5 3 8 9 r = 8 s = 1 7 2 12 10 4 6 11 5 3 8 9 r = 11 s = 8 3 5 11 6 4 10 12 2 7 1 9 r = 3 s = 5 3 8 11 6 4 10 12 2 7 1 9 r = 8 s = 12 10 4 6 11 8 3 5 2 7 1 9 r = 12 s = 9 1 7 2 5 3 8 11 6 4 10 12 r = 6 s = 3 5 2 7 1 9 8 11 6 4 10 r = 8 s = 11 8 9 1 7 2 5 3 6 4 10 r = 4 s = 1 9 8 11 7 2 5 3 6 4 10 r = 8 s = 3 5 2 7 11 8 9 1 6 4 10 r = 3 s = 2 5 3 7 11 8 9 1 6 4 10 r = 5 s = 11 7 3 5 2 8 9 1 6 4 10 r = 2 s = 7 11 3 5 2 8 9 1 6 4 10 r = 2 s = 11 7 3 5 2 8 9 1 6 4 10 r = 10 s = 4 6 1 9 8 2 5 3 7 11 10 r = 5 s = 8 9 1 6 4 2 5 3 7 11 10 r = 6 s = 2 4 6 1 9 8 5 3 7 11 10 r = 3 s = 6 4 2 1 9 8 5 3 7 11 10 r = 3 s = 2 4 6 1 9 8 5 3 7 11 10 r = 10 s = 11 7 3 5 8 9 1 6 4 2 10 r = 10 s = 2 4 6 1 9 8 5 3 7 11 10 r = 10 s = 11 7 3 5 8 9 1 6 4 2 10 r = 11 s = 10 2 4 6 1 9 8 5 3 7 11 r = 6 s = 9 1 6 4 2 10 8 5 3 7 r = 3 s = 6 1 9 4 2 10 8 5 3 7 r = 7 s = 8 10 2 4 9 1 6 5 3 7 r = 2 s = 10 8 2 4 9 1 6 5 3 7 r = 9 s = 3 5 6 1 9 4 2 8 10 7 r = 10 s = 7 10 8 2 4 9 1 6 5 3 r = 8 s = 6 1 9 4 2 8 10 7 5 3 r = 5 s = 2 4 9 1 6 8 10 7 5 3 r = 8 s = 7 10 8 6 1 9 4 2 5 3 r = 4 s = 6 8 10 7 1 9 4 2 5 3 r = 6 s = 9 1 7 10 8 6 4 2 5 3 r = 10 s = 3 5 2 4 6 8 10 7 1 9 r = 9 s = 1 7 10 8 6 4 2 5 3 9 r = 10 s = 9 3 5 2 4 6 8 10 7 1 r = 5 s = 4 2 5 3 9 6 8 10 7 1 r = 6 s = 6 9 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 s = 7 4 5 1 9 2 3 6 8 r = 7 s = 3 2 9 1 5 4 7 6 8 r = 9 s = 8 6 7 4 5 1 9 2 3 r = 5 s = 5 4 7 6 8 1 9 2 3 r = 3 s = 7 4 5 6 8 1 9 2 3 r = 7 s = 9 1 8 6 5 4 7 2 3 r = 8 s = 2 7 4 5 6 8 1 9 3 r = 6 s = 8 6 5 4 7 2 1 9 3 r = 5 s = 7 4 5 6 8 2 1 9 3 r = 6 s = 2 8 6 5 4 7 1 9 3 r = 3 s = 6 8 2 5 4 7 1 9 3 r = 5 s = 4 5 ...

Array indices must be positive integers or logical values. Error in sort_pancakes (line 3) while s(end)<numel(s) Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in Test3 (line 2) for spatula = sort_pancakes(x)

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

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

Array indices must be positive integers or logical values. Error in sort_pancakes (line 3) while s(end)<numel(s) Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in Test4 (line 2) for spatula = sort_pancakes(x)

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

Array indices must be positive integers or logical values. Error in sort_pancakes (line 3) while s(end)<numel(s) Error in sort_pancakes (line 8) [ans sort_pancakes(s(1:end-1))]; Error in Test5 (line 3) for spatula = sort_pancakes(x)

Suggested Problems

More from this Author41