Cody

Problem 534. Find best domino orientation

Created by Doug Hull in Community

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

41.81% Correct | 58.19% Incorrect
Last solution submitted on Feb 16, 2019

Problem Comments

Solution Comments

Recent Solvers163

Suggested Problems

More from this Author52

Tags

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!