Cody

# Problem 534. Find best domino orientation

Solution 1180552

Submitted on 4 May 2017 by arvid Martens
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 = [5 2 3 7 4 9 2 3 8 2 3 5 8 2 7 8 4 2 8 2]; y_correct = [0 0 1 1 1 1 1 1 0 1]; assert(isequal(findBestDominoeOrientation(list),y_correct))

C = Columns 1 through 29 35 36 37 34 29 30 37 34 35 36 37 34 29 30 37 34 35 36 37 34 29 30 37 34 33 34 35 32 27 Columns 30 through 58 28 35 32 39 40 41 38 33 34 41 38 39 40 41 38 33 34 41 38 35 36 37 34 29 30 37 34 33 34 Columns 59 through 87 35 32 27 28 35 32 31 32 33 30 25 26 33 30 31 32 33 30 25 26 33 30 31 32 33 30 25 26 33 Columns 88 through 116 30 29 30 31 28 23 24 31 28 31 32 33 30 25 26 33 30 31 32 33 30 25 26 33 30 27 28 29 26 Columns 117 through 145 21 22 29 26 25 26 27 24 19 20 27 24 35 36 37 34 29 30 37 34 35 36 37 34 29 30 37 34 35 Columns 146 through 174 36 37 34 29 30 37 34 33 34 35 32 27 28 35 32 39 40 41 38 33 34 41 38 39 40 41 38 33 34 Columns 175 through 203 41 38 35 36 37 34 29 30 37 34 33 34 35 32 27 28 35 32 29 30 31 28 23 24 31 28 29 30 31 Columns 204 through 232 28 23 24 31 28 29 30 31 28 23 24 31 28 27 28 29 26 21 22 29 26 29 30 31 28 23 24 31 28 Columns 233 through 261 29 30 31 28 23 24 31 28 25 26 27 24 19 20 27 24 23 24 25 22 17 18 25 22 35 36 37 34 29 Columns 262 through 290 30 37 34 35 36 37 34 29 30 37 34 35 36 37 34 29 30 37 34 33 34 35 32 27 28 35 32 39 40 Columns 291 through 319 41 38 33 34 41 38 39 40 41 38 33 34 41 38 35 36 37 34 29 30 37 34 33 34 35 32 27 28 35 Columns 320 through 348 32 31 32 33 30 25 26 33 30 31 32 33 30 25 26 33 30 31 32 33 30 25 26 33 30 29 30 31 28 Columns 349 through 377 23 24 31 28 31 32 33 30 25 26 33 30 31 32 33 30 25 26 33 30 27 28 29 26 21 22 29 26 25 Columns 378 through 406 26 27 24 19 20 27 24 35 36 37 34 29 30 37 34 35 36 37 34 29 30 37 34 35 36 37 34 29 30 Columns 407 through 435 37 34 33 34 35 32 27 28 35 32 39 40 41 38 33 34 41 38 39 40 41 38 33 34 41 38 35 36 37 Columns 436 through 464 34 29 30 37 34 33 34 35 32 27 28 35 32 29 30 31 28 23 24 31 28 29 30 31 28 23 24 31 28 Columns 465 through 493 29 30 31 28 23 24 31 28 27 28 29 26 21 22 29 26 29 30 31 28 23 24 31 28 29 30 31 28 23 Columns 494 through 522 24 31 28 25 26 27 24 19 20 27 24 23 24 25 22 17 18 25 22 29 30 31 28 23 24 31 28 29 30 Columns 523 through 551 31 28 23 24 31 28 29 30 31 28 23 24 31 28 27 28 29 26 21 22 29 26 33 34 35 32 27 28 35 Columns 552 through 580 32 33 34 35 32 27 28 35 32 29 30 31 28 23 24 31 28 27 28 29 26 21 22 29 26 25 26 27 24 Columns 581 through 609 19 20 27 24 25 26 27 24 19 20 27 24 25 26 27 24 19 20 27 24 23 24 25 22 17 18 25 22 25 Columns 610 through 638 26 27 24 19 20 27 24 25 26 27 24 19 20 27 24 21 22 23 20 15 16 23 20 19 20 21 18 13 14 Columns 639 through 667 21 18 29 30 31 28 23 24 31 28 29 30 31 28 23 24 31 28 29 30 31 28 23 24 31 28 27 28 29 Columns 668 through 696 26 21 22 29 26 33 34 35 32 27 28 35 32 33 34 35 32 27 28 35 32 29 30 31 28 23 24 31 28 Columns 697 through 725 27 28 29 26 21 22 29 26 23 24 25 22 17 18 25 22 23 24 25 22 17 18 25 22 23 24 25 22 17 Columns 726 through 754 18 25 22 21 22 23 20 15 16 23 20 23 24 25 22 17 18 25 22 23 24 25 22 17 18 25 22 19 20 Columns 755 through 783 21 18 13 14 21 18 17 18 19 16 11 12 19 16 33 34 35 32 27 28 35 32 33 34 35 32 27 28 35 Columns 784 through 812 32 33 34 35 32 27 28 35 32 31 32 33 30 25 26 33 30 37 38 39 36 31 32 39 36 37 38 39 36 Columns 813 through 841 31 32 39 36 33 34 35 32 27 28 35 32 31 32 33 30 25 26 33 30 29 30 31 28 23 24 31 28 29 Columns 842 through 870 30 31 28 23 24 31 28 29 30 31 28 23 24 31 28 27 28 29 26 21 22 29 26 29 30 31 28 23 24 Columns 871 through 899 31 28 29 30 31 28 23 24 31 28 25 26 27 24 19 20 27 24 23 24 25 22 17 18 25 22 33 34 35 Columns 900 through 928 32 27 28 35 32 33 34 35 32 27 28 35 32 33 34 35 32 27 28 35 32 31 32 33 30 25 26 33 30 Columns 929 through 957 37 38 39 36 31 32 39 36 37 38 39 36 31 32 39 36 33 34 35 32 27 28 35 32 31 32 33 30 25 Columns 958 through 986 26 33 30 27 28 29 26 21 22 29 26 27 28 29 26 21 22 29 26 27 28 29 26 21 22 29 26 25 26 Columns 987 through 1015 27 24 19 20 27 24 27 28 29 26 21 22 29 26 27 28 29 26 21 22 29 26 23 24 25 22 17 18 25 Columns 1016 through 1024 22 21 22 23 20 15 16 23 20

2   Pass
list = [0 8 4 8 2 0 8 0 5 7 7 2 1 6 2 6 2 7 0 2]; y_correct = [0 1 0 1 1 1 1 0 1 1]; assert(isequal(findBestDominoeOrientation(list),y_correct))

C = Columns 1 through 29 39 39 31 39 39 39 31 39 29 29 21 29 33 33 25 33 43 43 35 43 43 43 35 43 29 29 21 29 33 Columns 30 through 58 33 25 33 49 49 41 49 49 49 41 49 39 39 31 39 43 43 35 43 49 49 41 49 49 49 41 49 35 35 Columns 59 through 87 27 35 39 39 31 39 39 39 31 39 39 39 31 39 29 29 21 29 33 33 25 33 43 43 35 43 43 43 35 Columns 88 through 116 43 29 29 21 29 33 33 25 33 41 41 33 41 41 41 33 41 31 31 23 31 35 35 27 35 41 41 33 41 Columns 117 through 145 41 41 33 41 27 27 19 27 31 31 23 31 31 31 23 31 31 31 23 31 21 21 13 21 25 25 17 25 35 Columns 146 through 174 35 27 35 35 35 27 35 21 21 13 21 25 25 17 25 41 41 33 41 41 41 33 41 31 31 23 31 35 35 Columns 175 through 203 27 35 41 41 33 41 41 41 33 41 27 27 19 27 31 31 23 31 39 39 31 39 39 39 31 39 29 29 21 Columns 204 through 232 29 33 33 25 33 43 43 35 43 43 43 35 43 29 29 21 29 33 33 25 33 41 41 33 41 41 41 33 41 Columns 233 through 261 31 31 23 31 35 35 27 35 41 41 33 41 41 41 33 41 27 27 19 27 31 31 23 31 31 31 23 31 31 Columns 262 through 290 31 23 31 21 21 13 21 25 25 17 25 35 35 27 35 35 35 27 35 21 21 13 21 25 25 17 25 41 41 Columns 291 through 319 33 41 41 41 33 41 31 31 23 31 35 35 27 35 41 41 33 41 41 41 33 41 27 27 19 27 31 31 23 Columns 320 through 348 31 31 31 23 31 31 31 23 31 21 21 13 21 25 25 17 25 35 35 27 35 35 35 27 35 21 21 13 21 Columns 349 through 377 25 25 17 25 33 33 25 33 33 33 25 33 23 23 15 23 27 27 19 27 33 33 25 33 33 33 25 33 19 Columns 378 through 406 19 11 19 23 23 15 23 31 31 23 31 31 31 23 31 21 21 13 21 25 25 17 25 35 35 27 35 35 35 Columns 407 through 435 27 35 21 21 13 21 25 25 17 25 41 41 33 41 41 41 33 41 31 31 23 31 35 35 27 35 41 41 33 Columns 436 through 464 41 41 41 33 41 27 27 19 27 31 31 23 31 39 39 31 39 39 39 31 39 29 29 21 29 33 33 25 33 Columns 465 through 493 43 43 35 43 43 43 35 43 29 29 21 29 33 33 25 33 41 41 33 41 41 41 33 41 31 31 23 31 35 Columns 494 through 522 35 27 35 41 41 33 41 41 41 33 41 27 27 19 27 31 31 23 31 37 37 29 37 37 37 29 37 27 27 Columns 523 through 551 19 27 31 31 23 31 41 41 33 41 41 41 33 41 27 27 19 27 31 31 23 31 47 47 39 47 47 47 39 Columns 552 through 580 47 37 37 29 37 41 41 33 41 47 47 39 47 47 47 39 47 33 33 25 33 37 37 29 37 37 37 29 37 Columns 581 through 609 37 37 29 37 27 27 19 27 31 31 23 31 41 41 33 41 41 41 33 41 27 27 19 27 31 31 23 31 39 Columns 610 through 638 39 31 39 39 39 31 39 29 29 21 29 33 33 25 33 39 39 31 39 39 39 31 39 25 25 17 25 29 29 Columns 639 through 667 21 29 29 29 21 29 29 29 21 29 19 19 11 19 23 23 15 23 33 33 25 33 33 33 25 33 19 19 11 Columns 668 through 696 19 23 23 15 23 39 39 31 39 39 39 31 39 29 29 21 29 33 33 25 33 39 39 31 39 39 39 31 39 Columns 697 through 725 25 25 17 25 29 29 21 29 37 37 29 37 37 37 29 37 27 27 19 27 31 31 23 31 41 41 33 41 41 Columns 726 through 754 41 33 41 27 27 19 27 31 31 23 31 39 39 31 39 39 39 31 39 29 29 21 29 33 33 25 33 39 39 Columns 755 through 783 31 39 39 39 31 39 25 25 17 25 29 29 21 29 29 29 21 29 29 29 21 29 19 19 11 19 23 23 15 Columns 784 through 812 23 33 33 25 33 33 33 25 33 19 19 11 19 23 23 15 23 39 39 31 39 39 39 31 39 29 29 21 29 Columns 813 through 841 33 33 25 33 39 39 31 39 39 39 31 39 25 25 17 25 29 29 21 29 29 29 21 29 29 29 21 29 19 Columns 842 through 870 19 11 19 23 23 15 23 33 33 25 33 33 33 25 33 19 19 11 19 23 23 15 23 31 31 23 31 31 31 Columns 871 through 899 23 31 21 21 13 21 25 25 17 25 31 31 23 31 31 31 23 31 17 17 9 17 21 21 13 21 29 29 21 Columns 900 through 928 29 29 29 21 29 19 19 11 19 23 23 15 23 33 33 25 33 33 33 25 33 19 19 11 19 23 23 15 23 Columns 929 through 957 39 39 31 39 39 39 31 39 29 29 21 29 33 33 25 33 39 39 31 39 39 39 31 39 25 25 17 25 29 Columns 958 through 986 29 21 29 37 37 29 37 37 37 29 37 27 27 19 27 31 31 23 31 41 41 33 41 41 41 33 41 27 27 Columns 987 through 1015 19 27 31 31 23 31 39 39 31 39 39 39 31 39 29 29 21 29 33 33 25 33 39 39 31 39 39 39 31 Columns 1016 through 1024 39 25 25 17 25 29 29 21 29

3   Pass
list = [7 5 3 1 5 1 6 5 4 8 2 6 5 1 1 3 5 9 9 2 0 7 1 7]; y_correct = [0 0 1 1 1 0 0 0 0 0 0 1]; assert(isequal(findBestDominoeOrientation(list),y_correct))

C = Columns 1 through 29 29 31 29 31 21 23 25 27 29 31 29 31 21 23 25 27 27 29 27 29 19 21 23 25 25 27 25 27 17 Columns 30 through 58 19 21 23 27 29 27 29 19 21 23 25 27 29 27 29 19 21 23 25 29 31 29 31 21 23 25 27 27 29 Columns 59 through 87 27 29 19 21 23 25 37 39 37 39 29 31 33 35 37 39 37 39 29 31 33 35 35 37 35 37 27 29 31 Columns 88 through 116 33 33 35 33 35 25 27 29 31 29 31 29 31 21 23 25 27 29 31 29 31 21 23 25 27 31 33 31 33 Columns 117 through 145 23 25 27 29 29 31 29 31 21 23 25 27 33 35 33 35 25 27 29 31 33 35 33 35 25 27 29 31 31 Columns 146 through 174 33 31 33 23 25 27 29 29 31 29 31 21 23 25 27 31 33 31 33 23 25 27 29 31 33 31 33 23 25 Columns 175 through 203 27 29 33 35 33 35 25 27 29 31 31 33 31 33 23 25 27 29 37 39 37 39 29 31 33 35 37 39 37 Columns 204 through 232 39 29 31 33 35 35 37 35 37 27 29 31 33 33 35 33 35 25 27 29 31 29 31 29 31 21 23 25 27 Columns 233 through 261 29 31 29 31 21 23 25 27 31 33 31 33 23 25 27 29 29 31 29 31 21 23 25 27 37 39 37 39 29 Columns 262 through 290 31 33 35 37 39 37 39 29 31 33 35 35 37 35 37 27 29 31 33 33 35 33 35 25 27 29 31 35 37 Columns 291 through 319 35 37 27 29 31 33 35 37 35 37 27 29 31 33 37 39 37 39 29 31 33 35 35 37 35 37 27 29 31 Columns 320 through 348 33 45 47 45 47 37 39 41 43 45 47 45 47 37 39 41 43 43 45 43 45 35 37 39 41 41 43 41 43 Columns 349 through 377 33 35 37 39 37 39 37 39 29 31 33 35 37 39 37 39 29 31 33 35 39 41 39 41 31 33 35 37 37 Columns 378 through 406 39 37 39 29 31 33 35 41 43 41 43 33 35 37 39 41 43 41 43 33 35 37 39 39 41 39 41 31 33 Columns 407 through 435 35 37 37 39 37 39 29 31 33 35 39 41 39 41 31 33 35 37 39 41 39 41 31 33 35 37 41 43 41 Columns 436 through 464 43 33 35 37 39 39 41 39 41 31 33 35 37 45 47 45 47 37 39 41 43 45 47 45 47 37 39 41 43 Columns 465 through 493 43 45 43 45 35 37 39 41 41 43 41 43 33 35 37 39 37 39 37 39 29 31 33 35 37 39 37 39 29 Columns 494 through 522 31 33 35 39 41 39 41 31 33 35 37 37 39 37 39 29 31 33 35 43 45 43 45 35 37 39 41 43 45 Columns 523 through 551 43 45 35 37 39 41 41 43 41 43 33 35 37 39 39 41 39 41 31 33 35 37 41 43 41 43 33 35 37 Columns 552 through 580 39 41 43 41 43 33 35 37 39 43 45 43 45 35 37 39 41 41 43 41 43 33 35 37 39 51 53 51 53 Columns 581 through 609 43 45 47 49 51 53 51 53 43 45 47 49 49 51 49 51 41 43 45 47 47 49 47 49 39 41 43 45 43 Columns 610 through 638 45 43 45 35 37 39 41 43 45 43 45 35 37 39 41 45 47 45 47 37 39 41 43 43 45 43 45 35 37 Columns 639 through 667 39 41 47 49 47 49 39 41 43 45 47 49 47 49 39 41 43 45 45 47 45 47 37 39 41 43 43 45 43 Columns 668 through 696 45 35 37 39 41 45 47 45 47 37 39 41 43 45 47 45 47 37 39 41 43 47 49 47 49 39 41 43 45 Columns 697 through 725 45 47 45 47 37 39 41 43 51 53 51 53 43 45 47 49 51 53 51 53 43 45 47 49 49 51 49 51 41 Columns 726 through 754 43 45 47 47 49 47 49 39 41 43 45 43 45 43 45 35 37 39 41 43 45 43 45 35 37 39 41 45 47 Columns 755 through 783 45 47 37 39 41 43 43 45 43 45 35 37 39 41 43 45 43 45 35 37 39 41 43 45 43 45 35 37 39 Columns 784 through 812 41 41 43 41 43 33 35 37 39 39 41 39 41 31 33 35 37 41 43 41 43 33 35 37 39 41 43 41 43 Columns 813 through 841 33 35 37 39 43 45 43 45 35 37 39 41 41 43 41 43 33 35 37 39 51 53 51 53 43 45 47 49 51 Columns 842 through 870 53 51 53 43 45 47 49 49 51 49 51 41 43 45 47 47 49 47 49 39 41 43 45 43 45 43 45 35 37 Columns 871 through 899 39 41 43 45 43 45 35 37 39 41 45 47 45 47 37 39 41 43 43 45 43 45 35 37 39 41 47 49 47 Columns 900 through 928 49 39 41 43 45 47 49 47 49 39 41 43 45 45 47 45 47 37 39 41 43 43 45 43 45 35 37 39 41 Columns 929 through 957 45 47 45 47 37 39 41 43 45 47 45 47 37 39 41 43 47 49 47 49 39 41 43 45 45 47 45 47 37 Columns 958 through 986 39 41 43 51 53 51 53 43 45 47 49 51 53 51 53 43 45 47 49 49 51 49 51 41 43 45 47 47 49 Columns 987 through 1015 47 49 39 41 43 45 43 45 43 45 35 37 39 41 43 45 43 45 35 37 39 41 45 47 45 47 37 39 41 Columns 1016 through 1044 43 43 45 43 45 35 37 39 41 27 29 27 29 19 21 23 25 27 29 27 29 19 21 23 25 25 27 25 27 Columns 1045 through 1073 17 19 21 23 23 25 23 25 15 17 19 21 25 27 25 27 17 19 21 23 25 27 25 27 17 19 21 23 27 Columns 1074 through 1102 29 27 29 19 21 23 25 25 27 25 27 17 19 21 23 35 37 35 37 27 29 31 33 35 37 35 37 27 29 Columns 1103 through 1131 31 33 33 35 33 35 25 27 29 31 31 33 31 33 23 25 27 29 27 29 27 29 19 21 23 25 27 29 27 Columns 1132 through 1160 29 19 21 23 25 29 31 29 31 21 23 25 27 27 29 27 29 19 21 23 25 31 33 31 33 23 25 27 29 Columns 1161 through 1189 31 33 31 33 23 25 27 29 29 31 29 31 21 23 25 27 27 29 27 29 19 21 23 25 29 31 29 31 21 Columns 1190 through 1218 23 25 27 29 31 29 31 21 23 25 27 31 33 31 33 23 25 27 29 29 31 29 31 21 23 25 27 35 37 Columns 1219 through 1247 35 37 27 29 31 33 35 37 35 37 27 29 31 33 33 35 33 35 25 27 29 31 31 33 31 33 23 25 27 Columns 1248 through 1276 29 27 29 27 29 19 21 23 25 27 29 27 29 19 21 23 25 29 31 29 31 21 23 25 27 27 29 27 29 Columns 1277 through 1305 19 21 23 25 35 37 35 37 27 29 31 33 35 37 35 37 27 29 31 33 33 35 33 35 25 27 29 31 31 Columns 1306 through 1334 33 31 33 23 25 27 29 33 35 33 35 25 27 29 31 33 35 33 35 25 27 29 31 35 37 35 37 27 29 Columns 1335 through 1363 31 33 33 35 33 35 25 27 29 31 43 45 43 45 35 37 39 41 43 45 43 45 35 37 39 41 41 43 41 Columns 1364 through 1392 43 33 35 37 39 39 41 39 41 31 33 35 37 35 37 35 37 27 29 31 33 35 37 35 37 27 29 31 33 Columns 1393 through 1421 37 39 37 39 29 31 33 35 35 37 35 37 27 29 31 33 39 41 39 41 31 33 35 37 39 41 39 41 31 Columns 1422 through 1450...

4   Pass
list = [0 4 0 3 8 2 2 5]; y_correct = [1 0 1 1]; assert(isequal(findBestDominoeOrientation(list),y_correct))

C = 9 5 9 11 11 7 9 11 12 8 12 14 8 4 6 8