Cody

# Problem 492. Find best placement for ordered dominoes (harder)

Solution 239484

Submitted on 3 May 2013 by Clemens Giegerich
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
%% list = [4 1 3 4 1 1 5 5 3 5 0 4 2 0]; %2 correct = [2 1 3 7 6 5 4]; assert(isequal(findBestOrderedDominoes(list),correct))

score = 7 score = 10 score = 9 score = 3 score = 7 score = 4 score = 11 score = 12 score = 9 score = 11 score = 11 score = 14 score = 11 score = 13 score = 11 score = 5 score = 11 score = 7 score = 5 score = 8 score = 11 score = 9 score = 11 score = 12 score = 9 score = 12 score = 11 score = 5 score = 9 score = 6 score = 9 score = 10 score = 9 score = 9 score = 11 score = 12 score = 9 score = 11 score = 11 score = 5 score = 9 score = 5 score = 5 score = 6 score = 9 score = 9 score = 9 score = 10 score = 11 score = 12 score = 11 score = 11 score = 11 score = 12 score = 7 score = 8 score = 9 score = 11 score = 9 score = 12 score = 7 score = 11 score = 9 score = 9 score = 11 score = 7 score = 11 score = 10 score = 9 score = 11 score = 13 score = 14 score = 9 score = 11 score = 11 score = 5 score = 9 score = 5 score = 11 score = 11 score = 7 score = 11 score = 9 score = 13 score = 11 score = 13 score = 9 score = 3 score = 11 score = 7 score = 3 score = 7 score = 11 score = 7 score = 11 score = 11 score = 11 score = 12 score = 11 score = 11 score = 11 score = 12 score = 7 score = 8 score = 5 score = 3 score = 5 score = 4 score = 11 score = 7 score = 9 score = 9 score = 7 score = 11 score = 9 score = 12 score = 11 score = 9 score = 7 score = 8 score = 15 score = 18 score = 17 score = 11 score = 15 score = 12 score = 17 score = 18 score = 15 score = 17 score = 17 score = 20 score = 17 score = 19 score = 17 score = 11 score = 17 score = 13 score = 11 score = 14 score = 17 score = 15 score = 17 score = 18 score = 13 score = 16 score = 15 score = 9 score = 13 score = 10 score = 9 score = 10 score = 13 score = 10 score = 16 score = 12 score = 9 score = 12 score = 15 score = 9 score = 9 score = 6 score = 10 score = 6 score = 10 score = 13 score = 9 score = 10 score = 17 score = 18 score = 17 score = 14 score = 18 score = 14 score = 11 score = 12 score = 11 score = 13 score = 11 score = 14 score = 15 score = 17 score = 15 score = 12 score = 18 score = 11 score = 13 score = 14 score = 17 score = 18 score = 20 score = 20 score = 11 score = 14 score = 17 score = 11 score = 11 score = 8 score = 17 score = 14 score = 11 score = 13 score = 13 score = 20 score = 17 score = 19 score = 17 score = 11 score = 17 score = 13 score = 7 score = 14 score = 13 score = 11 score = 17 score = 14 score = 18 score = 14 score = 14 score = 17 score = 17 score = 18 score = 14 score = 14 score = 12 score = 11 score = 7 score = 8 score = 18 score = 11 score = 12 score = 15 score = 15 score = 17 score = 11 score = 14 score = 13 score = 11 score = 11 score = 12 score = 17 score = 20 score = 19 score = 13 score = 17 score = 14 score = 13 score = 14 score = 17 score = 14 score = 20 score = 16 score = 13 score = 16 score = 19 score = 13 score = 13 score = 10 score = 14 score = 10 score = 14 score = 17 score = 13 score = 14 score = 17 score = 20 score = 19 score = 13 score = 17 score = 14 score = 17 score = 18 score = 17 score = 17 score = 19 score = 20 score = 17 score = 19 score = 19 score = 13 score = 17 score = 13 score = 13 score = 14 score = 17 score = 17 score = 17 score = 18 score = 13 score = 14 score = 13 score = 13 score = 13 score = 14 score = 17 score = 18 score = 17 score = 14 score = 18 score = 14 score = 17 score = 14 score = 17 score = 17 score = 13 score = 18 score = 20 score = 20 score = 20 score = 19 score = 15 score = 16 score = 17 score = 19 score = 19 score = 13 score = 17 score = 13 score = 13 score = 13 score = 17 score = 14 score = 20 score = 15 score = 13 score = 16 score = 19 score = 13 score = 13 score = 10 score = 14 score = 9 score = 14 score = 17 score = 13 score = 13 score = 13 score = 14 score = 13 score = 13 score = 13 score = 14 score = 9 score = 10 score = 13 score = 14 score = 14 score = 14 score = 13 score = 18 score = 17 score = 17 score = 17 score = 14 score = 18 score = 14 score = 14 score = 17 score = 17 score = 18 score = 9 score = 10 score = 9 score = 6 score = 10 score = 6 score = 11 score = 12 score = 11 score = 13 score = 11 score = 14 score = 11 score = 13 score = 11 score = 8 score = 14 score = 7 score = 7 score = 8 score = 11 score = 12 score = 14 score = 14 score = 13 score = 14 score = 13 score = 10 score = 14 score = 10 score = 13 score = 14 score = 13 score = 13 score = 13 score = 14 score = 13 score = 13 score = 13 score = 10 score = 14 score = 9 score = 9 score = 10 score = 13 score = 14 score = 14 score = 14 score = 7 score = 8 score = 7 score = 7 score = 7 score = 8 score = 5 score = 6 score = 7 score = 9 score = 7 score = 10 score = 5 score = 9 score = 7 score = 7 score = 9 score = 5 score = 7 score = 6 score = 5 score = 7 score = 9 score = 10 score = 11 score = 11 score = 11 score = 8 score = 12 score = 7 score = 11 score = 11 score = 9 score = 13 score = 9 score = 13 score = 11 score = 13 score = 9 score = 6 score = 14 score = 7 score = 5 score = 7 score = 11 score = 10 score = 14 score = 13 score = 15 score = 16 score = 15 score = 16 score = 16 score = 16 score = 9 score = 10 score = 9 score = 7 score = 9 score = 8 score = 13 score = 11 score = 13 score = 14 score = 12 score = 13 score = 13 score = 14 score = 13 score = 14 score = 12 score = 12 score = 9 score = 12 score = 15 score = 9 score = 9 score = 6 score = 17 score = 14 score = 11 score = 13 score = 13 score = 20 score = 17 score = 19 score = 17 score = 11 score = 17 score = 13 score = 7 score = 14 score = 13 score = 11 score = 17 score = 14 score = 11 score = 14 score = 17 score = 11 score = 11 score = 8 score = 15 score = 12 score = 11 score = 11 score = 13 score = 18 score = 15 score = 17 score = 17 score = 11 score = 15 score = 11 score = 7 score = 12 score = 11 score = 11 score = 15 score = 12 score = 17 score = 14 score = 17 score = 17 score = 13 score = 18 score = 13 score = 10 score = 15 score = 17 score = 11 score = 18 score = 9 score = 13 score = 11 score = 11 score = 13 score = 9 score = 17 score = 16 score = 11 score = 13 score = 19 score = 20 score = 15 score = 17 score = 17 score = 11 score = 15 score = 11 score = 17 score = 17 score = 13 score = 17 score = 15 score = 19 score = 17 score = 19 score = 15 score = 9 score = 17 score = 13 score = 9 score = 13 score = 17 score = 13 score = 17 score = 17 score = 13 score = 18 score = 17 score = 17 score = 17 score = 14 score = 13 score = 14 score = 7 score = 5 score = 11 score = 10 score = 13 score = 9 score = 11 score = 11 score = 9 score = 13 score = 11 score = 18 score = 17 score = 15 score = 13 score = 10 score = 16 score = 12 score = 12 score = 15 score = 15 score = 16 score = 20 score = 20 score = 18 score = 17 score = 13 score = 14 score = 20 score = 13 score = 14 score = 17 score = 17 score = 19 score = 17 score = 20 score = 19 score = 17 score = 17 score = 18 score = 20 score = 16 score = 16 score = 19 score = 19 score = 20 score = 20 score = 20 score = 20 score = 19 score = 15 score = 16 score = 20 score = 15 score = 16 score = 19 score = 19 score = 19 score = 19 score = 20 score = 19 score = 19 score = 19 score = 20 score = 16 score = 16 score = 16 score = 15 score = 15 score = 16 score = 12 score = 12 score = 14 score = 13 score = 13 score = 14 score = 12 score = 13 score = 14 score = 13 score = 13 score = 11 score = ...

2   Fail
%% list = [1 1 2 5 7 5 8 1 1 3 7 8 3 6]; %3 correct = [2 6 4 1 5 7 3]; assert(isequal(findBestOrderedDominoes(list),correct))

score = 26 score = 24 score = 20 score = 24 score = 16 score = 22 score = 20 score = 16 score = 18 score = 26 score = 20 score = 24 score = 14 score = 22 score = 22 score = 18 score = 26 score = 22 score = 22 score = 20 score = 16 score = 20 score = 20 score = 26 score = 12 score = 10 score = 8 score = 12 score = 6 score = 12 score = 16 score = 14 score = 16 score = 14 score = 16 score = 12 score = 10 score = 8 score = 14 score = 14 score = 10 score = 16 score = 14 score = 12 score = 8 score = 10 score = 4 score = 8 score = 10 score = 8 score = 12 score = 10 score = 10 score = 6 score = 16 score = 12 score = 10 score = 18 score = 12 score = 16 score = 14 score = 18 score = 10 score = 8 score = 16 score = 14 score = 10 score = 12 score = 16 score = 10 score = 18 score = 14 score = 22 score = 20 score = 18 score = 18 score = 14 score = 20 score = 14 score = 12 score = 18 score = 22 score = 18 score = 20 score = 18 score = 26 score = 26 score = 22 score = 26 score = 22 score = 26 score = 20 score = 18 score = 22 score = 22 score = 28 score = 28 score = 26 score = 22 score = 24 score = 18 score = 22 score = 22 score = 18 score = 20 score = 26 score = 22 score = 24 score = 14 score = 20 score = 22 score = 16 score = 24 score = 20 score = 18 score = 16 score = 14 score = 18 score = 16 score = 22 score = 22 score = 20 score = 16 score = 20 score = 12 score = 18 score = 18 score = 14 score = 16 score = 24 score = 18 score = 22 score = 20 score = 28 score = 28 score = 24 score = 32 score = 28 score = 28 score = 26 score = 22 score = 26 score = 26 score = 32 score = 24 score = 22 score = 28 score = 32 score = 26 score = 32 score = 28 score = 26 score = 28 score = 29 score = 23 score = 32 score = 22 score = 23 score = 18 score = 26 score = 22 score = 23 score = 21 score = 24 score = 15 score = 14 score = 24 score = 20 score = 28 score = 26 score = 22 score = 23 score = 15 score = 24 score = 16 score = 12 score = 20 score = 28 score = 22 score = 26 score = 14 score = 28 score = 28 score = 21 score = 29 score = 22 score = 28 score = 20 score = 16 score = 23 score = 23 score = 32 score = 24 score = 25 score = 20 score = 28 score = 16 score = 17 score = 24 score = 17 score = 10 score = 24 score = 18 score = 25 score = 12 score = 20 score = 18 score = 14 score = 28 score = 24 score = 18 score = 25 score = 20 score = 22 score = 24 score = 25 score = 25 score = 28 score = 19 score = 18 score = 28 score = 24 score = 19 score = 28 score = 25 score = 18 score = 24 score = 16 score = 19 score = 12 score = 19 score = 18 score = 16 score = 14 score = 20 score = 18 score = 24 score = 28 score = 16 score = 22 score = 14 score = 12 score = 18 score = 22 score = 16 score = 22 score = 18 score = 16 score = 18 score = 19 score = 13 score = 22 score = 14 score = 15 score = 10 score = 18 score = 14 score = 15 score = 15 score = 18 score = 9 score = 8 score = 18 score = 14 score = 26 score = 24 score = 22 score = 26 score = 20 score = 26 score = 18 score = 16 score = 18 score = 16 score = 18 score = 14 score = 22 score = 20 score = 26 score = 26 score = 22 score = 28 score = 28 score = 26 score = 22 score = 24 score = 18 score = 22 score = 22 score = 20 score = 22 score = 20 score = 22 score = 18 score = 26 score = 24 score = 22 score = 23 score = 17 score = 26 score = 26 score = 23 score = 22 score = 20 score = 28 score = 19 score = 15 score = 22 score = 21 score = 22 score = 28 score = 26 score = 12 score = 10 score = 20 score = 20 score = 16 score = 22 score = 16 score = 14 score = 20 score = 17 score = 13 score = 22 score = 20 score = 21 score = 16 score = 24 score = 16 score = 17 score = 21 score = 22 score = 13 score = 12 score = 24 score = 18 score = 16 score = 14 score = 20 score = 22 score = 18 score = 22 score = 20 score = 18 score = 20 score = 19 score = 15 score = 22 score = 14 score = 13 score = 10 score = 16 score = 12 score = 13 score = 11 score = 14 score = 7 score = 6 score = 14 score = 10 score = 26 score = 24 score = 20 score = 21 score = 13 score = 22 score = 14 score = 10 score = 18 score = 26 score = 20 score = 24 score = 8 score = 22 score = 22 score = 15 score = 23 score = 16 score = 22 score = 14 score = 10 score = 17 score = 17 score = 26 score = 18 score = 16 score = 14 score = 15 score = 9 score = 18 score = 22 score = 20 score = 22 score = 20 score = 22 score = 18 score = 16 score = 14 score = 20 score = 17 score = 13 score = 22 score = 20 score = 18 score = 14 score = 13 score = 7 score = 14 score = 8 score = 6 score = 10 score = 8 score = 8 score = 4 score = 20 score = 16 score = 14 score = 22 score = 16 score = 20 score = 18 score = 22 score = 14 score = 12 score = 20 score = 18 score = 14 score = 16 score = 20 score = 14 score = 22 score = 18 score = 22 score = 20 score = 18 score = 15 score = 11 score = 20 score = 8 score = 6 score = 18 score = 22 score = 18 score = 20 score = 12 score = 26 score = 26 score = 19 score = 23 score = 16 score = 26 score = 14 score = 12 score = 19 score = 19 score = 28 score = 28 score = 26 score = 22 score = 21 score = 15 score = 22 score = 16 score = 12 score = 20 score = 26 score = 22 score = 24 score = 8 score = 20 score = 22 score = 13 score = 21 score = 14 score = 18 score = 10 score = 8 score = 15 score = 13 score = 22 score = 28 score = 29 score = 24 score = 32 score = 20 score = 21 score = 28 score = 21 score = 14 score = 28 score = 22 score = 29 score = 16 score = 24 score = 22 score = 18 score = 32 score = 28 score = 18 score = 25 score = 20 score = 22 score = 24 score = 25 score = 20 score = 21 score = 16 score = 24 score = 16 score = 17 score = 28 score = 25 score = 24 score = 22 score = 30 score = 21 score = 20 score = 18 score = 28 score = 28 score = 24 score = 30 score = 22 score = 21 score = 18 score = 24 score = 12 score = 13 score = 20 score = 17 score = 24 score = 22 score = 22 score = 13 score = 28 score = 21 score = 14 score = 28 score = 18 score = 25 score = 20 score = 24 score = 10 scor