Problem 782. Some Assembly Required

Created by James in Community

The input to this function is a matrix of real numbers. Your job is to assemble the rows of the matrix into one large row that contains all of the individual rows of the matrix, and to make this output row as short as possible. You accomplish this by joining the rows together at the points at which they overlap. To help with the task, you can flip rows if you need to do so.

For example:

input  = [1 1 2 3 ; 4 5 6 7 ; 5 4 8 3]
output = [1 1 2 3 8 4 5 6 7]

Explanation: The [1 1 2 3] is the first row of the input.

[3 8 4 5] is the third row (flipped) so the 3 at the end of the third row overlaps with the 3 at the end of the first row.

[4 5 6 7] is the second row, with the [4 5] overlapping with the flipped [5 4] from the third row.

Other than the mirrored version of the solution ([7 6 5 4 8 3 2 1 1] in the above example), each solution will be unique. Flipped versions of the entered value of y_correct will be tested for as well, in case your code comes up with that version of the correct answer.

Good luck, and happy hunting.

Solution Stats

28.57% Correct | 71.43% Incorrect
Last solution submitted on Feb 22, 2019

Problem Comments

Solution Comments

Recent Solvers47

Suggested Problems

More from this Author80

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!