Problem 2409. Find the Connecting Path
Here is a matrix x
x = [7 6 8 5 7 2 4 5 1 3 0 0 0 7 7 7 7 7 0 0 0 0 0 0 0 0 0 0 0 5 5 5 5 5 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 2 2 2 2 2 2 2 0 0 6 6 6 6 6 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 2 2 2 0 0 0 0 0 0 0 4 4 4 4 4 4 4 0 0 8 8 8 8 8 0 0 0 0 0 0 0 0 4 4 4 4 4 4 4 4 4 4 4 0 3 4 1 7 6 8 0 0 2 9 0 0]
If n = 7 then the output matrix y should be
y = [1 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0]
All the places of n = 7 will become 1 and horizontally they are connected by a path given by 1's which is represented in the output y.
If n = 9 then y(12,11) = 1 and others are 0's.
Output should display path as per given n.
Solution Stats
Problem Comments
-
6 Comments
Starting from the top you should travel to bottom. Repeating no. displays vertical path and you should think about only horizontal missing places.
forget the logic. Your test suite 2 is still broken
This problem needs to have its description improved. It is not clear why some path must prefered over another like on test case #2. Why the fours must cross at the borders when the sevens didn't? Can we only add one 1 per row? and what's the priority of paths?
Solution Comments
Show commentsProblem Recent Solvers15
Suggested Problems
-
Find the peak 3n+1 sequence value
2526 Solvers
-
Get the area codes from a list of phone numbers
1062 Solvers
-
Sum of diagonal of a square matrix
1589 Solvers
-
Output any real number that is neither positive nor negative
399 Solvers
-
606 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!