Problem 782. Some Assembly Required
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
Problem Comments
-
6 Comments
I've added some randomness to the test suite questions to stop the look-up tables from working properly. Thanks for the heads up on that. As you may have noticed, it's been a while since I submitted this problem!
Solutions aren't unique: f([1;2;3]) = {[1,2,3],[1,3,2],[2,1,3]}
Nice problem!
Solution Comments
Show commentsGroup

Project Euler I
- 10 Problems
- 852 Finishers
- Project Euler: Problem 1, Multiples of 3 and 5
- Project Euler: Problem 2, Sum of even Fibonacci
- Project Euler: Problem 3, Largest prime factor
- Project Euler: Problem 4, Palindromic numbers
- Project Euler: Problem 5, Smallest multiple
- Project Euler: Problem 6, Natural numbers, squares and sums.
- Project Euler: Problem 7, Nth prime
- Project Euler: Problem 8, Find largest product in a large string of numbers
- Project Euler: Problem 9, Pythagorean numbers
- Project Euler: Problem 10, Sum of Primes
Problem Recent Solvers99
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!