Cody

Solution 2450367

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 ans = 1 ans = 5 ans = 4 ans = 3 ans = 2

Output argument "y" (and maybe others) not assigned during call to "sort_pancakes". 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))

t = 1 6 5 4 3 2 ans = 2 ans = 4 ans = 6 ans = 3 ans = 5 ans = 1

Output argument "y" (and maybe others) not assigned during call to "sort_pancakes". 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))

t = 1 12 11 10 9 8 7 6 5 4 3 2 ans = 10 ans = 5 ans = 9 ans = 4 ans = 1 ans = 7 ans = 11 ans = 2 ans = 8 ans = 3 ans = 12 ans = 6

Output argument "y" (and maybe others) not assigned during call to "sort_pancakes". 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))

t = 1 13 12 11 10 9 8 7 6 5 4 3 2 ans = 5 ans = 7 ans = 13 ans = 1 ans = 10 ans = 11 ans = 3 ans = 8 ans = 6 ans = 9 ans = 2 ans = 12 ans = 4

Output argument "y" (and maybe others) not assigned during call to "sort_pancakes". 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

t = 1 ans = 1

Output argument "y" (and maybe others) not assigned during call to "sort_pancakes". Error in Test5 (line 3) for spatula = sort_pancakes(x)