A picross, also known as a nonogram, is a logic puzzle in which the player is given an initially blank grid and must shade in particular boxes on the grid to reveal an image. Numbers are written on the top and the left side, and they explain the image's coloration: each number corresponds to an unbroken line of shaded-in boxes in its row or column. Consider any individual row or column from this completed puzzle to see this correspondence:
Not shown in the image is the fact that one can write an "X" to indicate that a box is known not to be shaded in. Partially solving a row or column by shading in and crossing out boxes provides necessary information for the rest of the puzzle, as rows and columns usually cannot be completely solved on their own (for instance, in the image, this is only possible in the first row).
To take the hints for a given row along with the state of each box in the row as inputs, and output the row solved to the fullest extent possible.
In these examples, let
0 represent a box with an "X",
1 a shaded-in box, and
2 an unknown or unknowable (that is, blank) box.
This row would be input as
and the program should output the following:
This output corresponds to this row, and no more information can be found:
The boxes marked
1 are always that way, no matter the arrangement of the shading. Essentially, if a box always has the same state, it must assume that state, lest the shading contradicts what is known. If there is not a unanimous agreement, then the box is unknowable and is marked
Input: [1,3,7,1], [2,2,2,2,2,2,0,2,2,2,2,2,2,2,2,2,2,2,2,2] Output: [2,2,2,2,2,2,0,2,2,2,2,1,1,1,2,2,2,2,2,2]
Input: , [2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2] Output: [0,0,0,0,0,0,0,2,2,2,2,2,1,2,2,2,2,2,0,0,0,0,0,0,0]
If a 6-wide shading were to begin in any of the first 7 boxes, the row would have to have
 as its hints, and so none of the first 7 boxes can be filled in. The same is true for the right side.
Input: , [2,0,2,2,2,2,0,2] Output: [0,0,2,1,1,2,0,0]
Because a 3-wide shading can only fit in the 4-wide gap in the middle, the 1-wide gaps on the edges can be turned into
Any three distinct symbols may be used in the place of
2so long as it is indicated which symbol corresponds to which state
Assume the input hints and row never form an impossible combination
This is code-golf, so the shortest program in bytes in each language wins