Cody

# Problem 487. Find perfect placement of non-rotating dominoes (easier)

Solution 803192

Submitted on 8 Jan 2016 by Michael Cappello
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 = [ 1 5 2 1 2 2 3 2 4 8 5 4 5 5 10 3]; correct = [8 4 3 2 1 7 6 5]; assert(isequal(findPerfectOrderedDominoes(list),correct))

s = 1 order = 8 2 7 3 4 5 6 1 x = 10 2 5 2 3 4 5 1 3 1 5 2 2 8 4 5 x = 10 3 2 1 5 5 2 2 3 2 4 8 5 4 1 5 x = 3 2 1 5 5 2 2 3 2 4 8 5 4 1 x = -1 -1 4 0 -3 0 1 -1 2 4 -3 -1 -3 s = 17 order = 6 1 7 5 4 3 2 8 x = 5 1 5 4 3 2 2 10 4 5 5 8 2 2 1 3 x = 5 4 1 5 5 5 4 8 3 2 2 2 2 1 10 3 x = 4 1 5 5 5 4 8 3 2 2 2 2 1 10 x = -3 4 0 0 -1 4 -5 -1 0 0 0 -1 9 s = 18 order = 8 5 7 4 6 3 2 1 x = 10 4 5 3 5 2 2 1 3 8 5 2 4 2 1 5 x = 10 3 4 8 5 5 3 2 5 4 2 2 2 1 1 5 x = 3 4 8 5 5 3 2 5 4 2 2 2 1 1 x = 1 4 -3 0 -2 -1 3 -1 -2 0 0 -1 0 s = 11 order = 5 4 8 7 2 6 3 1 x = 4 3 10 5 2 5 2 1 8 2 3 5 1 4 2 5 x = 4 8 3 2 10 3 5 5 2 1 5 4 2 2 1 5 x = 8 3 2 10 3 5 5 2 1 5 4 2 2 1 x = -5 -1 8 -7 2 0 -3 -1 4 -1 -2 0 -1 s = 25 order = 4 3 8 6 5 7 1 2 x = 3 2 10 5 4 5 1 2 2 2 3 4 8 5 5 1 x = 3 2 2 2 10 3 5 4 4 8 5 5 1 5 2 1 x = 2 2 2 10 3 5 4 4 8 5 5 1 5 2 x = 0 0 8 -7 2 -1 0 4 -3 0 -4 4 -3 s = 20 order = 1 3 8 7 2 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1 -2 0 2 s = 19 order = 2 6 8 7 1 5 4 3 x = 2 5 10 5 1 4 3 2 1 4 3 5 5 8 2 2 x = 2 1 5 4 10 3 5 5 1 5 4 8 3 2 2 2 x = 1 5 4 10 3 5 5 1 5 4 8 3 2 2 x = 4 -1 6 -7 2 0 -4 4 -1 4 -5 -1 0 s = 22 order = 7 6 1 3 4 5 8 2 x = 5 5 1 2 3 4 10 2 5 4 5 2 2 8 3 1 x = 5 5 5 4 1 5 2 2 3 2 4 8 10 3 2 1 x = 5 5 4 1 5 2 2 3 2 4 8 10 3 2 x = 0 -1 -3 4 -3 0 1 -1 2 4 2 -7 -1 s = 12 order = 6 7 4 1 3 2 8 5 x = 5 5 3 1 2 2 10 4 4 5 2 5 2 1 3 8 x = 5 4 5 5 3 2 1 5 2 2 2 1 10 3 4 8 x = 4 5 5 3 2 1 5 2 2 2 1 10 3 4 x = 1 0 -2 -1 -1 4 -3 0 0 -1 9 -7 1 s = 17 order = 4 6 5 1 2 3 7 8 x = 3 5 4 1 2 2 5 10 2 4 8 5 1 2 5 3 x = 3 2 5 4 4 8 1 5 2 1 2 2 5 5 10 3 x = 2 5 4 4 8 1 5 2 1 2 2 5 5 10 x = 3 -1 0 4 -7 4 -3 -1 1 0 3 0 5 s = 22 order = 5 1 6 7 8 3 4 2 x = 4 1 5 5 10 2 3 2 8 5 4 5 3 2 2 1 x = 4 8 1 5 5 4 5 5 10 3 2 2 3 ...

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

s = 1 order = 7 3 1 2 5 6 4 8 x = 10 2 1 2 7 8 7 10 2 7 6 2 8 10 1 10 x = 10 2 2 7 1 6 2 2 7 8 8 10 7 1 10 10 x = 2 2 7 1 6 2 2 7 8 8 10 7 1 10 x = 0 5 -6 5 -4 0 5 1 0 2 -3 -6 9 s = 27 order = 3 4 6 5 8 2 1 7 x = 2 7 8 7 10 2 1 10 7 1 10 8 10 2 6 2 x = 2 7 7 1 8 10 7 8 10 10 2 2 1 6 10 2 x = 7 7 1 8 10 7 8 10 10 2 2 1 6 10 x = 0 -6 7 2 -3 1 2 0 -8 0 -1 5 4 s = 25 order = 1 2 8 7 6 4 3 5 x = 1 2 10 10 8 7 2 7 6 2 10 2 10 1 7 8 x = 1 6 2 2 10 10 10 2 8 10 7 1 2 7 7 8 x = 6 2 2 10 10 10 2 8 10 7 1 2 7 7 x = -4 0 8 0 0 -8 6 2 -3 -6 1 5 0 s = 22 order = 2 5 8 1 6 4 7 3 x = 2 7 10 1 8 7 10 2 2 8 10 6 10 1 2 7 x = 2 2 7 8 10 10 1 6 8 10 7 1 10 2 2 7 x = 2 7 8 10 10 1 6 8 10 7 1 10 2 2 x = 5 1 2 0 -9 5 2 2 -3 -6 9 -8 0 s = 30 order = 7 6 8 2 4 3 5 1 x = 10 8 10 2 7 2 7 1 2 10 10 2 1 7 8 6 x = 10 2 8 10 10 10 2 2 7 1 2 7 7 8 1 6 x = 2 8 10 10 10 2 2 7 1 2 7 7 8 1 x = 6 2 0 0 -8 0 5 -6 1 5 0 1 -7 s = 27 order = 1 6 5 4 8 3 2 7 x = 1 8 7 7 10 2 2 10 6 10 8 1 10 7 2 2 x = 1 6 8 10 7 8 7 1 10 10 2 7 2 2 10 2 x = 6 8 10 7 8 7 1 10 10 2 7 2 2 10 x = 2 2 -3 1 -1 -6 9 0 -8 5 -5 0 8 s = 36 order = 7 6 2 3 1 5 4 8 x = 10 8 2 2 1 7 7 10 2 10 2 7 6 8 1 10 x = 10 2 8 10 2 2 2 7 1 6 7 8 7 1 10 10 x = 2 8 10 2 2 2 7 1 6 7 8 7 1 10 x = 6 2 -8 0 0 5 -6 5 1 1 -1 -6 9 s = 31 order = 8 5 6 4 7 2 1 3 x = 10 7 8 7 10 2 1 2 10 8 10 1 2 2 6 7 x = 10 10 7 8 8 10 7 1 10 2 2 2 1 6 2 7 x = 10 7 8 8 10 7 1 10 2 2 2 1 6 2 x = -3 1 0 2 -3 -6 9 -8 0 0 -1 5 -4 s = 20 order = 2 4 3 5 7 1 8 6 x = 2 7 2 7 10 1 10 8 2 1 7 8 2 6 10 10 x = 2 2 7 1 2 7 7 8 10 2 1 6 10 10 8 10 x = 2 7 1 2 7 7 8 10 2 1 6 10 10 8 x = 5 -6 1 5 0 1 2 -8 -1 5 4 0 -2 s = 15 order = 7 1 5 8 6 3 2 4 x = 10 1 7 10 8 2 2 7 2 6 8 10 10 7 2 1 x = 10 2 1 6 7 8 10 10 8 10 2 7 2 2 7 1 x = 2 1 6 7 8 10 10 8 10 2 7 2 2 7 x = -1 5 1 1 2 0 -2 2 -8 5 -5 0 5 s = 24 order = 1 3 7 5 8 4 6 2 x = 1 2 10 7 10 7 8 2 6 7 2 8 10 1 10 2 x = 1 6 2 7 10 2 7 8 10 10 7 1 8 10 2 2 x = 6 2 7 10 2 7 8 10 10 7 1 8 10 2 x = -4 5 3 -8 5 1 2 0 -3 -6 7 2 -8 s = 32 order = 3 2 6 4 1 8 5 7 x = 2 2 8 7 1 10 7 10 7 2 10 1 6 10 8 2 x = 2 7 2 2 8 10 7 1 1 6 10 10 7 8 10 2 x = 7 2 2 8 10 7 1 1 6 10 10 7 8 10 x = -5 0 6 2 -3 -6 0 5 4 0 -3 1 2 s = 23 order = 3 6 4 5 1 8 2 7 x = 2 8 7 7 1 10 2 10 7 10 1 8 6 10 2 2 x = 2 7 8 10 7 1 7 8 1 6 10 10 2 2 10 2 x = 7 8 10 7 1 7 8 1 6 10 10 2 2 10 x = 1 2 -3 -6 6 1 -7 5 4 0 -8 0 8 s = 37 order = 1 8 5 7 6 3 4 2 x = 1 10 7 10 8 2 7 2 6 10 8 2 10 7 1 2 x = 1 6 10 10 7 8 10 2 8 10 2 7 7 1 2 2 x = 6 10 10 7 8 10 2 8 10 2 7 7 1 2 x = 4 0 -3 1 2 -8 6 2 -8 5 0 -6 1 s = 24 order = 5 6 7 3 4 1 8 2 x = 7 8 10 2 7 1 10 2 8 10 2 7 1 6 10 2 x = 7 8 8 10 10 2 2 7 7 1 1 6 10 10 2 2 x = 8 8 10 10 2 2 7 7 1 1 6 10 10 2 x = 0 2 0 -8 0 5 0 -6 0 5 4 0 -8 s = 12 order = 8 1 2 4 5 6 3 7 x = 10 1 2 7 7 8 2 10 10 6 2 1 8 10 7 2 x = 10 10 1 6 2 2 7 1 7 8 8 10 2 7 10 2 x = 10 1 6 2 2 7 1 7 8 8 10 2 7 10 x = -9 5 -4 0 5 -6 6 1 0 2 -8 5 3 s = 35 order = 5 8 2 6 7 1 3 4 x = 7 10 2 8 10 1 2 7 8 10 2 10 2 6 7 1 x = 7 8 10 10 2 2 8 10 10 2 1 6 2 7 7 1 x = 8 10 10 2 2 8 10 10 2 1 6 2 7 7 x = 2 0 -8 0 6 2 0 -8 -1 5 -4 5 0 s = 21 order = 3 7 1 8 4 5 6 2 x = 2 10 1 10 7 7 8 2 7 2 6 10 1 8 10 2 x = 2 7 10 2 1 6 10 10 7 1 7 8 8 10 2 2 x = 7 10 2 1 6 10 10 7 1 7 8 8 10 2 x = 3 -8 -1 5 4 0 -3 -6 6 1 0 2 -8 s = 25 order = 6 1 2 7 4 3 5 8 x = 8 1 2 10 7 2 7 10 10 6 2 2 1 7 8 10 x = 8 10 1 6 2 2 10 2 7 1 2 7 7 8 10 10 x = 10 1 6 2 2 10 2 7 1 2 7 7 8 10 x = -9 5 -4 0 8 -8 5 -6 1 5 0 1 2 s = 29 order = 5 4 3 2 1 7 8 6 x = 7 7 2 2 1 10 10 8 8 1 7 2 6 2 10 10 x = 7 8 7 1 2 7 2 2 1 6 10 2 10 10 8 10 x = 8 7 1 2 7 2 2 1 6 10 2 10 10 8 x = -1 -6 1 5 -5 0 -1 5 4 -8 8 0 -2 s = 22 order = 1 8 2 7 6 3 4 5 x = 1 10 2 10 8 2 7 7 6 10 2 2 10 7 1 8 x = 1 6 10 10 2 2 10 2 8 10 2 7 7 1 7 8 x = 6 10 10 2 2 10 2 8 10 2 7 7 1 7 x = 4 0 -8 0 8 -8 6 2 -8 5 0 -6 6 s = 40 order = 4 3 1 7 2 6 8 5 x = 7 2 1 10 2 8 10 7 1 7 6 2 2 10 10 8 x = 7 1 2 7 1 6 10 2 2 2 8 10 10 10 7 8 x = 1 2 7 1 6 10 2 2 2 8 10 10 10 7 x = 1 5 -6 5 4 -8 0 0 6 2 0 0 -3 s = 20 order = 2 3 5 6 1 8 4 7 x = 2 2 7 8 1 10 7 10 2 7 8 10 6 10 1 2 x = 2 2 2 7 7 8 8 10 1 6 10 10 7 ...

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

s = 1 order = 1 8 6 5 7 4 2 3 x = 1 7 6 5 7 4 1 2 1 5 2 1 4 6 7 4 x = 1 1 7 5 6 2 5 1 7 4 4 6 1 7 2 4 x = 1 7 5 6 2 5 1 7 4 4 6 1 7 2 x = 6 -2 1 -4 3 -4 6 -3 0 2 -5 6 -5 s = 26 order = 6 2 3 1 4 8 7 5 x = 6 1 2 1 4 7 7 5 2 7 4 1 6 5 4 1 x = 6 2 1 7 2 4 1 1 4 6 7 5 7 4 5 1 x = 2 1 7 2 4 1 1 4 6 7 5 7 4 5 x = -1 6 -5 2 -3 0 3 2 1 -2 2 -3 1 s = 16 order = 3 1 4 5 8 6 2 7 x = 2 1 4 5 7 6 1 7 4 1 6 1 5 2 7 4 x = 2 4 1 1 4 6 5 1 7 5 6 2 1 7 7 4 x = 4 1 1 4 6 5 1 7 5 6 2 1 7 7 x = -3 0 3 2 -1 -4 6 -2 1 -4 -1 6 0 s = 15 order = 5 7 8 6 1 2 4 3 x = 5 7 7 6 1 1 4 2 1 4 5 2 1 7 6 4 x = 5 1 7 4 7 5 6 2 1 1 1 7 4 6 2 4 x = 1 7 4 7 5 6 2 1 1 1 7 4 6 2 x = 6 -3 3 -2 1 -4 -1 0 0 6 -3 2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 0 2 0 2 1 -2 -4 0 0 6 -2 s = 9 order = 8 4 2 7 5 6 1 3 x = 7 4 1 7 5 6 1 2 5 6 7 4 1 2 1 4 x = 7 5 4 6 1 7 7 4 5 1 6 2 1 1 2 4 x = 5 4 6 1 7 7 4 5 1 6 2 1 1 2 x = -1 2 -5 6 0 -3 1 -4 5 -4 -1 0 1 s = 14 order = 8 1 4 7 3 6 5 2 x = 7 1 4 7 2 6 5 1 5 1 6 4 4 2 1 7 x = 7 5 1 1 4 6 7 4 2 4 6 2 5 1 1 7 x = 5 1 1 4 6 7 4 2 4 6 2 5 1 1 x = -4 0 3 2 1 -3 -2 2 2 -4 3 -4 0 s = 15 order = 6 5 4 8 2 7 1 3 x = 6 5 4 7 1 7 1 2 2 1 6 5 7 4 1 4 x = 6 2 5 1 4 6 7 5 1 7 7 4 1 1 2 4 x = 2 5 1 4 6 7 5 1 7 7 4 1 1 2 x = 3 -4 3 2 1 -2 -4 6 0 -3 -3 0 1 s = 15 order = 5 1 7 6 2 3 4 8 x = 5 1 7 6 1 2 4 7 1 1 4 2 7 4 6 5 x = 5 1 1 1 7 4 6 2 1 7 2 4 4 6 7 5 x = 1 1 1 7 4 6 2 1 7 2 4 4 6 7 x = 0 0 6 -3 2 -4 -1 6 -5 2 0 2 1 s = 15 order = 2 3 8 6 4 5 1 7 x = 1 2 7 6 4 5 1 7 7 4 5 2 6 1 1 4 x = 1 7 2 4 7 5 6 2 4 6 5 1 1 1 7 4 x = 7 2 4 7 5 6 2 4 6 5 1 1 1 7 x = -5 2 3 -2 1 -4 2 2 -1 -4 0 0 6 s = 18 order = 6 4 5 3 2 1 8 7 x = 6 4 5 2 1 1 7 7 2 6 1 4 7 1 5 4 x = 6 2 4 6 5 1 2 4 1 7 1 1 7 ...

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

s = 1 order = 5 7 2 6 3 9 8 4 1 x = 7 8 3 8 5 10 9 6 1 6 8 10 7 3 5 1 9 10 x = Columns 1 through 16 7 6 8 8 3 10 8 7 5 3 10 5 9 1 6 9 Columns 17 through 18 1 10 x = 6 8 8 3 10 8 7 5 3 10 5 9 1 6 9 1 x = 2 0 -5 7 -2 -1 -2 -2 7 -5 4 -8 5 3 -8 s = 35 order = 6 8 5 9 4 1 7 3 2 x = 8 9 7 10 6 1 8 5 3 7 1 6 5 9 10 8 3 10 x = Columns 1 through 16 8 7 9 1 7 6 10 5 6 9 1 10 8 8 5 3 Columns 17 through 18 3 10 x = 7 9 1 7 6 10 5 6 9 1 10 8 8 5 3 3 x = 2 -8 6 -1 4 -5 1 3 -8 9 -2 0 -3 -2 0 s = 26 order = 8 7 2 1 6 4 5 9 3 x = 9 8 3 1 8 6 7 10 5 1 8 10 10 7 9 6 5 3 x = Columns 1 through 16 9 1 8 8 3 10 1 10 8 7 6 9 7 6 10 5 Columns 17 through 18 5 3 x = 1 8 8 3 10 1 10 8 7 6 9 7 6 10 5 5 x = 7 0 -5 7 -9 9 -2 -1 -1 3 -2 -1 4 -5 0 s = 30 order = 2 4 8 1 9 6 3 7 5 x = 3 6 9 1 10 8 5 8 7 10 9 1 10 5 7 3 8 6 x = Columns 1 through 16 3 10 6 9 9 1 1 10 10 5 8 7 5 3 8 8 Columns 17 through 18 7 6 x = 10 6 9 9 1 1 10 10 5 8 7 5 3 8 8 7 x = -4 3 0 -8 0 9 0 -5 3 -1 -2 -2 5 0 -1 s = 15 order = 4 3 7 2 6 9 8 5 1 x = 6 5 8 3 8 10 9 7 1 9 3 8 10 7 5 1 6 10 x = Columns 1 through 16 6 9 5 3 8 8 3 10 8 7 10 5 9 1 7 6 Columns 17 through 18 1 10 x = 9 5 3 8 8 3 10 8 7 10 5 9 1 7 6 1 x = -4 -2 5 0 -5 7 -2 -1 3 -5 4 -8 6 -1 -5 s = 34 order = 5 7 4 2 1 9 3 8 6 x = 7 8 6 3 1 10 5 9 8 6 8 9 10 10 5 3 1 7 x = Columns 1 through 16 7 6 8 8 6 9 3 10 1 10 10 5 5 3 9 1 Columns 17 through 18 8 7 x = 6 8 8 6 9 3 10 1 10 10 5 5 3 9 1 8 x = 2 0 -2 3 -6 7 -9 9 0 -5 0 -2 6 -8 7 s = 32 order = 4 6 3 5 7 8 2 9 1 x = 6 8 5 7 8 9 3 10 1 9 7 3 6 8 1 10 5 10 x = Columns 1 through 16 6 9 8 7 5 3 7 6 8 8 9 1 3 10 10 5 Columns 17 through 18 1 10 x = 9 8 7 5 3 7 6 8 8 9 1 3 10 10 5 1 x = -1 -1 -2 -2 4 -1 2 0 1 -8 2 7 0 -5 -4 s = 16 order = 5 4 2 8 6 3 9 7 1 x = 7 6 3 9 8 5 10 8 1 6 9 10 1 7 3 5 8 10 x = Columns 1 through 16 7 6 6 9 3 10 9 1 8 7 5 3 10 5 8 8 Columns 17 through 18 1 10 x = 6 6 9 3 10 9 1 8 7 5 3 10 5 8 8 1 x = 0 3 -6 7 -1 -8 7 -1 -2 -2 7 -5 3 0 -7 s = 33 order = 6 2 3 9 4 1 8 5 7 x = 8 3 5 10 6 1 9 7 8 7 10 3 5 9 10 1 6 8 x = Columns 1 through 16 8 7 3 10 5 3 10 5 6 9 1 10 9 1 7 6 Columns 17 through 18 8 8 x = 7 3 10 5 3 10 5 6 9 1 10 9 1 7 6 8 x = -4 7 -5 -2 7 -5 1 3 -8 9 -1 -8 6 -1 2 s = 34 order = 9 4 8 6 2 1 5 7 3 x = 10 6 9 8 3 1 7 8 5 5 9 1 7 10 10 6 8 3 x = Columns 1 through 16 10 5 6 9 9 1 8 7 3 10 1 10 7 6 8 8 Columns 17 through 18 5 3 x = 5 6 9 9 1 8 7 3 10 1 10 7 6 8 8 5 x = 1 3 0 -8 7 -1 -4 7 -9 9 -3 -1 2 0 -3 s = 29 order = 6 7 5 4 3 2 8 1 9 x = 8 8 7 6 5 3 9 1 10 7 8 6 9 3 10 1 10 5 x = Columns 1 through 16 8 7 8 8 7 6 6 9 5 3 3 10 9 1 1 10 Columns 17 through 18 10 5 x = 7 8 8 7 6 6 9 5 3 3 10 9 1 1 10 10 x = 1 0 -1 -1 0 3 -4 -2 0 7 -1 -8 0 9 0 s = 7 order = 5 3 2 1 8 6 9 4 7 x = 7 5 3 1 9 8 10 6 8 6 3 10 10 1 7 5 9 8 x = Columns 1 through 16 7 6 5 3 3 10 1 10 9 1 8 7 10 5 6 9 Columns 17 through 18 8 8 x = 6 5 3 3 10 1 10 9 1 8 7 10 5 6 9 8 x = -1 -2 0 7 -9 9 -1 -8 7 -1 3 -5 1 3 -1 s = 23 order = 3 5 7 6 4 9 2 1 8 x = 5 7 8 8 6 10 3 1 9 3 6 8 7 9 5 10 10 1 x = Columns 1 through 16 5 3 7 6 8 8 8 7 6 9 10 5 3 10 1 10 Columns 17 through 18 9 1 x = 3 7 6 8 8 8 7 6 9 10 5 3 10 1 10 9 x = 4 -1 2 0 0 -1 -1 3 1 -5 -2 7 -9 9 -1 s = 20 order = 5 9 3 7 8 4 2 1 6 x = 7 10 5 8 9 6 3 1 8 6 5 3 8 1 9 10 10 7 x = Columns 1 through 16 7 6 10 5 5 3 8 8 9 1 6 9 3 10 1 10 Columns 17 through 18 8 7 x = 6 10 5 5 3 8 8 9 1 6 9 3 10 1 10 8 x = 4 -5 0 -2 5 0 1 -8 5 3 -6 7 -9 9 -2 s = 32 order = 6 4 5 3 7 1 8 9 2 x = 8 6 7 5 8 1 9 10 3 7 9 6 3 8 10 1 5 10 x = Columns 1 through 16 8 7 6 9 7 6 5 3 8 8 1 10 9 1 10 5 Columns 17 through 18 3 10 x = 7 6 9 7 6 5 3 8 8 1 10 9 1 10 5 3 x = -1 3 -2 -1 -1 -2 5 0 -7 9 -1 -8 9 -5 -2 s = 28 order = 5 2 3 9 1 4 8 7 6 x = 7 3 5 10 1 6 9 8 8 6 10 3 5 10 9 1 8 7 x = Columns 1 through 16 7 6 3 10 5 3 10 5 1 10 6 9 9 1 8 8 Columns 17 through 18 8 7 x = 6 3 10 5 3 10 5 1 10 6 9 9 1 8 8 8 x = -3 7 -5 -2 7 -5 -4 9 -4 3 0 -8 7 0 0 s = 30 order = 5 9 7 1 6 4 2 3 8 x = 7 10 8 1 8 6 3 5 9 6 5 8 10 7 9 10 3 1 x = Columns 1 through 16 7 6 10 5 8 8 1 10 8 7 6 9 3 10 5 3 Columns 17 through 18 9 1 x = 6 10 5 8 8 1 10 8 7 6 9 3 10 5 3 9 x = 4 -5 3 0 -7 9 -2 -1 -1 3 -6 7 -5 -2 6 s = 34 order = 4 8 3 6 5 7 1 9 2 x = 6 9 5 8 7 8 1 10 3 9 1 3 7 6 8 10 5 10 x = Columns 1 through 16 6 9 9 1 5 3 8 7 7 6 8 8 1 10 10 5 Columns 17 through 18 3 10 x = 9 9 1 5 3 8 7 7 6 8 8 1 10 10 5 3 x = 0 -8 4 -2 5 -1 0 -1 2 0 -7 9 0 -5 -2 s = 20 order = 7 2 9 5 1 3 6 4 8 x = 8 3 10 7 1 5 8 6 9 8 10 5 6 10 3 7 9 1 x...