Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 254425

Submitted on 5 Jun 2013 by andrea84

Correct

305Size
Leading solution size is 217.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
deck = [1 4 7 10 13 16 19 22 25 28 3 6 9 12 15 18 21 24 27 2 5 8 11 14 17 20 23 26];
m    = 10;
out = [8    26     1     4     7    23     8     8     4    24];
assert(isequal(solitaire(deck, m),out))
k =
     8
k =
     8    26
k =
     8    26     1
k =
     8    26     1     4
k =
     8    26     1     4     7
k =
     8    26     1     4     7    23
k =
     8    26     1     4     7    23     8
k =
     8    26     1     4     7    23     8     8
k =
     8    26     1     4     7    23     8     8     4
k =
     8    26     1     4     7    23     8     8     4    24
2
Pass
 
%%
deck = 1:28;
m    = 10;
out = [3    22     9     4    23     7    25    16    14    14];
assert(isequal(solitaire(deck, m),out))
k =
     3
k =
     3    22
k =
     3    22     9
k =
     3    22     9     4
k =
     3    22     9     4    23
k =
     3    22     9     4    23     7
k =
     3    22     9     4    23     7    25
k =
     3    22     9     4    23     7    25    16
k =
     3    22     9     4    23     7    25    16    14
k =
     3    22     9     4    23     7    25    16    14    14
3
Pass
 
%%
deck = 1:28;
m    = 10;
out = [3    22     9     4    23     7    25    16    14    14];
assert(isequal(solitaire(deck, m),out))
k =
     3
k =
     3    22
k =
     3    22     9
k =
     3    22     9     4
k =
     3    22     9     4    23
k =
     3    22     9     4    23     7
k =
     3    22     9     4    23     7    25
k =
     3    22     9     4    23     7    25    16
k =
     3    22     9     4    23     7    25    16    14
k =
     3    22     9     4    23     7    25    16    14    14
4
Pass
 
%%
deck = 1:5;
m    = 10;
out = [3     4     1     1     5     5     4     2     4     1];
assert(isequal(solitaire(deck, m),out))
k =
     3
k =
     3     4
k =
     3     4     1
k =
     3     4     1     1
k =
     3     4     1     1     5
k =
     3     4     1     1     5     5
k =
     3     4     1     1     5     5     4
k =
     3     4     1     1     5     5     4     2
k =
     3     4     1     1     5     5     4     2     4
k =
     3     4     1     1     5     5     4     2     4     1