Cody

Solution 1313987

Submitted on 25 Oct 2017 by Eric G.
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
deck = 1:28; n = 10; out = [3 22 9 4 23 7 25 16 14 14]; assert(isequal(solitaire(deck, n),out))

deck = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 28 27 deck = 1 28 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 s3a = 2 s3b = 28 s3 = 2 28 deck = 28 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 1 deck = 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 1 out = 3 deck = 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 28 27 1 deck = 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 1 28 s3a = 28 s3b = 26 s3 = 26 28 deck = 27 1 28 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 deck = 25 27 1 28 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 out = 3 22 deck = 25 1 27 28 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 deck = 25 1 27 2 3 28 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 s3a = 6 s3b = 3 s3 = 3 6 deck = 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 27 2 3 28 25 1 deck = 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 27 2 3 28 25 4 1 out = 3 22 9 deck = 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 2 27 3 28 25 4 1 deck = 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 2 27 3 25 4 28 1 s3a = 27 s3b = 23 s3 = 23 27 deck = 1 27 3 25 4 28 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 2 deck = 3 25 4 28 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 27 2 out = 3 22 9 4 deck = 3 25 4 28 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 2 27 deck = 3 25 4 5 6 28 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 2 27 s3a = 6 s3b = 28 s3 = 6 28 deck = 28 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 2 27 3 25 4 5 6 deck = 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 2 27 3 25 4 5 28 7 8 9 10 11 6 out = 3 22 9 4 23 deck = 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 2 3 27 25 4 5 28 7 8 9 10 11 6 deck = 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 2 3 27 25 4 5 7 8 28 9 10 11 6 s3a = 24 s3b = 18 s3 = 18 24 deck = 9 10 11 6 27 25 4 5 7 8 28 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 2 3 deck = 6 27 25 4 5 7 8 28 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 2 9 10 11 3 out = 3 22 9 4 23 7 deck = 6 25 27 4 5 7 8 28 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 2 9 10 11 3 deck = 6 25 27 4 5 7 8 12 13 28 14 15 16 17 18 19 20 21 22 23 24 26 1 2 9 10 11 3 s3a = 10 s3b = 3 s3 = 3 10 deck = 14 15 16 17 18 19 20 21 22 23 24 26 1 2 9 10 11 3 27 4 5 7 8 12 13 28 6 25 deck = 28 6 14 15 16 17 18 19 20 21 22 23 24 26 1 2 9 10 11 3 27 4 5 7 8 12 13 25 out = 3 22 9 4 23 7 25 deck = 28 6 14 15 16 17 18 19 20 21 22 23 24 26 1 2 9 10 11 3 4 27 5 7 8 12 13 25 deck = 6 14 28 15 16 17 18 19 20 21 22 23 24 26 1 2 9 10 11 3 4 27 5 7 8 12 13 25 s3a = 3 s3b = 22 s3 = 3 22 deck = 5 7 8 12 13 25 28 15 16 17 18 19 20 21 22 23 24 26 1 2 9 10 11 3 4 27 6 14 deck = 22 23 24 26 1 2 9 10 11 3 4 27 6 5 7 8 12 13 25 28 15 16 17 18 19 20 21 14 out = 3 22 9 4 23 7 25 16 deck = 22 23 24 26 1 2 9 10 11 3 4 6 27 5 7 8 12 13 25 28 15 16 17 18 19 20 21 14 deck = 22 23 24 26 1 2 9 10 11 3 4 6 27 5 7 8 12 13 25 15 16 28 17 18 19 20 21 14 s3a = 22 s3b = 13 s3 = 13 22 deck = 17 18 19 20 21 14 27 5 7 8 12 13 25 15 16 28 22 23 24 26 1 2 9 10 11 3 4 6 deck = 27 5 7 8 12 13 25 15 16 28 22 23 24 26 1 2 9 10 11 3 4 17 18 19 20 21 14 6 out = 3 22 9 4 23 7 25 16 14 deck = 5 27 7 8 12 13 25 15 16 28 22 23 24 26 1 2 9 10 11 3 4 17 18 19 20 21 14 6 deck = 5 27 7 8 12 13 25 15 16 22 23 28 24 26 1 2 9 10 11 3 4 17 18 19 20 21 14 6 s3a = 12 s3b = 2 s3 = 2 12 deck = 24 26 1 2 9 10 11 3 4 17 18 19 20 21 14 6 27 7 8 12 13 25 15 16 22 23 28 5 deck = 10 11 3 4 17 18 19 20 21 14 6 27 7 8 12 13 25 15 16 22 23 28 24 26 1 2 9 5 out = 3 22 9 4 23 7 25 16 14 14

2   Pass
deck = 1:28; n = 9; out = [3 22 9 4 23 7 25 16 14]; assert(isequal(solitaire(deck, n),out))

deck = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 28 27 deck = 1 28 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 s3a = 2 s3b = 28 s3 = 2 28 deck = 28 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 1 deck = 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 1 out = 3 deck = 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 28 27 1 deck = 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 1 28 s3a = 28 s3b = 26 s3 = 26 28 deck = 27 1 28 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 deck = 25 27 1 28 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 out = 3 22 deck = 25 1 27 28 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 deck = 25 1 27 2 3 28 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 s3a = 6 s3b = 3 s3 = 3 6 deck = 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 27 2 3 28 25 1 deck = 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 27 2 3 28 25 4 1 out = 3 22 9 deck = 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 2 27 3 28 25 4 1 deck = 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 2 27 3 25 4 28 1 s3a = 27 s3b = 23 s3 = 23 27 deck = 1 27 3 25 4 28 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 2 deck = 3 25 4 28 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 27 2 out = 3 22 9 4 deck = 3 25 4 28 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 2 27 deck = 3 25 4 5 6 28 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 2 27 s3a = 6 s3b = 28 s3 = 6 28 deck = 28 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 2 27 3 25 4 5 6 deck = 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 2 27 3 25 4 5 28 7 8 9 10 11 6 out = 3 22 9 4 23 deck = 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 2 3 27 25 4 5 28 7 8 9 10 11 6 deck = 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 2 3 27 25 4 5 7 8 28 9 10 11 6 s3a = 24 s3b = 18 s3 = 18 24 deck = 9 10 11 6 27 25 4 5 7 8 28 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 2 3 deck = 6 27 25 4 5 7 8 28 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 2 9 10 11 3 out = 3 22 9 4 23 7 deck = 6 25 27 4 5 7 8 28 12 13 14 15 16 17 18 19 20 21 22 23 24 26 1 2 9 10 11 3 deck = 6 25 27 4 5 7 8 12 13 28 14 15 16 17 18 19 20 21 22 23 24 26 1 2 9 10 11 3 s3a = 10 s3b = 3 s3 = 3 10 deck = 14 15 16 17 18 19 20 21 22 23 24 26 1 2 9 10 11 3 27 4 5 7 8 12 13 28 6 25 deck = 28 6 14 15 16 17 18 19 20 21 22 23 24 26 1 2 9 10 11 3 27 4 5 7 8 12 13 25 out = 3 22 9 4 23 7 25 deck = 28 6 14 15 16 17 18 19 20 21 22 23 24 26 1 2 9 10 11 3 4 27 5 7 8 12 13 25 deck = 6 14 28 15 16 17 18 19 20 21 22 23 24 26 1 2 9 10 11 3 4 27 5 7 8 12 13 25 s3a = 3 s3b = 22 s3 = 3 22 deck = 5 7 8 12 13 25 28 15 16 17 18 19 20 21 22 23 24 26 1 2 9 10 11 3 4 27 6 14 deck = 22 23 24 26 1 2 9 10 11 3 4 27 6 5 7 8 12 13 25 28 15 16 17 18 19 20 21 14 out = 3 22 9 4 23 7 25 16 deck = 22 23 24 26 1 2 9 10 11 3 4 6 27 5 7 8 12 13 25 28 15 16 17 18 19 20 21 14 deck = 22 23 24 26 1 2 9 10 11 3 4 6 27 5 7 8 12 13 25 15 16 28 17 18 19 20 21 14 s3a = 22 s3b = 13 s3 = 13 22 deck = 17 18 19 20 21 14 27 5 7 8 12 13 25 15 16 28 22 23 24 26 1 2 9 10 11 3 4 6 deck = 27 5 7 8 12 13 25 15 16 28 22 23 24 26 1 2 9 10 11 3 4 17 18 19 20 21 14 6 out = 3 22 9 4 23 7 25 16 14