Cody

# Problem 766. Implement Solitaire cipher for N long deck.

Solution 99023

Submitted on 15 Jun 2012 by Aurelien Queffurust
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 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))

maxi2 = 28 out = 8 out = 8 26 out = 8 26 1 out = 8 26 1 4 out = 8 26 1 4 7 out = 8 26 1 4 7 23 out = 8 26 1 4 7 23 8 out = 8 26 1 4 7 23 8 8 out = 8 26 1 4 7 23 8 8 4 out = 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))

maxi2 = 28 C = Columns 1 through 10 1 28 3 4 5 6 7 8 9 10 Columns 11 through 20 11 12 13 14 15 16 17 18 19 20 Columns 21 through 28 21 22 23 24 25 26 28 27 C = Columns 1 through 10 1 28 2 3 4 5 6 7 8 9 Columns 11 through 20 10 11 12 13 14 15 16 17 18 19 Columns 21 through 28 20 21 22 23 24 25 26 27 C = Columns 1 through 10 1 28 2 3 4 5 6 7 8 9 Columns 11 through 20 10 11 12 13 14 15 16 17 18 19 Columns 21 through 28 20 21 22 23 24 25 26 27 out = 3 out = 3 22 out = 3 22 9 out = 3 22 9 4 out = 3 22 9 4 23 out = 3 22 9 4 23 7 out = 3 22 9 4 23 7 25 out = 3 22 9 4 23 7 25 16 out = 3 22 9 4 23 7 25 16 14 out = 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))

maxi2 = 28 C = Columns 1 through 10 1 28 3 4 5 6 7 8 9 10 Columns 11 through 20 11 12 13 14 15 16 17 18 19 20 Columns 21 through 28 21 22 23 24 25 26 28 27 C = Columns 1 through 10 1 28 2 3 4 5 6 7 8 9 Columns 11 through 20 10 11 12 13 14 15 16 17 18 19 Columns 21 through 28 20 21 22 23 24 25 26 27 C = Columns 1 through 10 1 28 2 3 4 5 6 7 8 9 Columns 11 through 20 10 11 12 13 14 15 16 17 18 19 Columns 21 through 28 20 21 22 23 24 25 26 27 out = 3 out = 3 22 out = 3 22 9 out = 3 22 9 4 out = 3 22 9 4 23 out = 3 22 9 4 23 7 out = 3 22 9 4 23 7 25 out = 3 22 9 4 23 7 25 16 out = 3 22 9 4 23 7 25 16 14 out = 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))

maxi2 = 5 C = 1 5 3 5 4 C = 1 5 2 3 4 C = 1 5 2 3 4 out = 3 out = 3 4 C = 2 5 4 5 3 C = 2 5 1 4 3 C = 2 5 1 4 3 out = 3 4 1 C = 1 5 4 5 2 C = 1 5 3 4 2 C = 1 5 3 4 2 out = 3 4 1 1 out = 3 4 1 1 5 C = 3 5 1 5 2 C = 3 5 4 1 2 C = 3 5 4 1 2 out = 3 4 1 1 5 5 C = 1 5 2 5 3 C = 1 5 4 2 3 C = 1 5 4 2 3 out = 3 4 1 1 5 5 4 out = 3 4 1 1 5 5 4 2 out = 3 4 1 1 5 5 4 2 4 C = 2 5 4 5 1 C = 2 5 3 4 1 C = 2 5 3 4 1 out = 3 4 1 1 5 5 4 2 4 1