Problem 1701. Solve the picross! (Hard)
Solve the picross!
http://en.wikipedia.org/wiki/Nonogram
The arguments (horz and vert) are cells containing the clues, e.g:
horz = { 2, [1, 1], [] }; vert = { 2, 1, 1 };
means
![](http://img15.hostingpics.net/thumbs/mini_268468DemoEmptyPicross.png)
You have to return the completed picross, a logical or double matrix with a 0 for a white case and a 1 for a black case. If we solve the previous example:
![](http://img15.hostingpics.net/thumbs/mini_676179DemoCompletedPicross.png)
So, the output argument should be:
picross = [ 1 1 0 ; 1 0 1 ; 0 0 0 ];
You have to do some guessings and optimize your code to pass the test suite.
Have fun!
See also: http://www.mathworks.fr/matlabcentral/cody/problems/1700-solve-the-picross-easy
Solution Stats
Problem Comments
-
3 Comments
A good challenging task. Very nice input format of cell arrays.
Solving a grid of 75x60 squares within Cody's time limit is extra hard. The greatest challenge is to find a fast code; recursion with backtracking no longer seems like a viable option. And I do hope the author is aware that nonograms are an NP-hard problem, which means there is no known fast algorithm to solve the general case: we have to build one for the specific cases of the test suite.
To any new challengers, know that only logic will not solve these puzzles. You will need some guessing, which means make the computer solve it as far as it can and then you, yes YOU, look at the picture (we humans can recognize the shape and finish the puzzle; the computer not so much). And, please, fell free to try some solvers out there.
Solution Comments
Show commentsProblem Recent Solvers4
Suggested Problems
-
Return a list sorted by number of occurrences
2765 Solvers
-
Count from 0 to N^M in base N.
235 Solvers
-
76 Solvers
-
Inhomogenous Depth Scale Interpolation
7 Solvers
-
Duplicate each element of a vector.
601 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!