Cody

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

Solution 1550949

Submitted on 6 Jun 2018 by David Verrelli
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))

bestScore = 7 bestOrder = 7 6 5 4 3 2 1 bestScore = 3 bestOrder = 7 6 5 4 2 1 3 bestScore = 2 bestOrder = 2 1 3 7 6 5 4

2   Pass
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))

bestScore = 26 bestOrder = 7 6 5 4 3 2 1 bestScore = 24 bestOrder = 7 6 5 4 3 1 2 bestScore = 20 bestOrder = 7 6 5 4 2 3 1 bestScore = 16 bestOrder = 7 6 5 4 1 2 3 bestScore = 14 bestOrder = 7 6 5 2 3 4 1 bestScore = 12 bestOrder = 7 6 4 5 3 2 1 bestScore = 10 bestOrder = 7 6 4 5 3 1 2 bestScore = 8 bestOrder = 7 6 4 5 2 3 1 bestScore = 6 bestOrder = 7 6 4 5 1 2 3 bestScore = 4 bestOrder = 7 6 4 1 5 2 3 bestScore = 3 bestOrder = 2 6 4 1 5 7 3

3   Pass
list = [8 5 3 9 10 6 6 2 2 17 18 14 9 5]; %6 correct = [3 1 2 7 4 5 6]; assert(isequal(findBestOrderedDominoes(list),correct))

bestScore = 48 bestOrder = 7 6 5 4 3 2 1 bestScore = 40 bestOrder = 7 6 5 4 2 3 1 bestScore = 34 bestOrder = 7 6 5 3 4 2 1 bestScore = 32 bestOrder = 7 6 4 5 3 2 1 bestScore = 28 bestOrder = 7 6 4 2 3 1 5 bestScore = 22 bestOrder = 7 6 3 4 2 1 5 bestScore = 16 bestOrder = 7 5 6 4 2 3 1 bestScore = 10 bestOrder = 7 5 6 3 4 2 1 bestScore = 9 bestOrder = 7 4 2 3 1 5 6 bestScore = 7 bestOrder = 7 2 3 1 4 5 6 bestScore = 6 bestOrder = 3 1 2 7 4 5 6