Find best domino orientation - MATLAB Cody - MATLAB Central

Problem 534. Find best domino orientation

Difficulty:Rate

Given a list of pairs, find the orientation they should be placed in a line, such that the sum of the absolute values of the differences is zero.

Zero means do not invert, One means invert in the order vector.

list = [1 2
        4 2
        2 3
order = [0 1 1]
yields: [1 2][2 4][3 2]
    or: abs(2-2) + abs(4-3)
    or:        0 + 1
    or: 1

There is a unique solution to this problem where the final score is minimized.

Solution Stats

36.16% Correct | 63.84% Incorrect
Last Solution submitted on Aug 16, 2025

Problem Comments

Solution Comments

Show comments
MATLAB EXPO 2025 Registration is Now Open! November 12 – 13, 2025
Registration is now open for MathWorks annual virtual event MATLAB EXPO 2025...
0
0

Problem Recent Solvers267

Suggested Problems

More from this Author51

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!