Cody

Solution 1609944

Submitted on 15 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
urlwrite('https://sites.google.com/a/alfnie.com/alfnie/software/SetSolutionScore.p?attredirects=0&d=1','SetSolutionScore.p'); rehash path;

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

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

Assertion failed.

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

Assertion failed.

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

Assertion failed.

6   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.

7   Fail
% this test may be extended and rescored sets = { [10 3 2 1 6 5 4 8 7 9] [10:-1:1] [1:10] [2:2:10 1:2:9] [ 9 8 14 5 12 1 10 13 2 7 6 3 15 4 11] [ 7 8 16 13 11 1 9 15 2 6 3 12 10 4 14 5] [ 15 14 19 1 9 4 12 3 16 7 13 20 6 2 11 10 17 5 8 18] [ 2 15 18 4 8 16 10 6 3 14 1 7 20 9 11 12 13 5 19 17 21] [ 5 1 9 3 18 22 17 15 11 16 10 13 2 21 20 6 12 7 23 8 19 14 4] [ 3 9 18 15 7 8 6 10 11 17 21 23 22 1 14 5 2 13 16 12 20 4 19] [ 34 71 51 31 55 61 18 26 59 8 14 6 70 1 25 7 9 4 44 39 19 56 22 32 27 2 11 28 68 57 49 48 20 29 13 10 17 40 3 37 45 63 73 30 43 42 38 21 23 46 62 47 58 69 24 65 60 36 72 64 54 33 5 52 67 66 15 53 12 35 41 16 50]}; for k = 1:numel(sets) x = sets{k}; queue = sort_pancakes(x); for spatula = queue x(1:spatula) = flip(x(1:spatula)); end assert(issorted(x)) n(k) = numel(x); score(k) = numel(queue); end SetSolutionScore(sum(score)); fprintf('\nTest %3d. %3d pancakes, %3d flips',[1:numel(sets); n; score]);

Assertion failed.