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
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:
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
-
Find S-parameters of the circuit
46 Solvers
-
516 Solvers
-
298 Solvers
-
190 Solvers
-
Calculate the area of a triangle between three points
2939 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!