问题
I need to build a nonogram solver according to a very specific recipe. For each row, I need to calculate all possible mutations, and then check if that row would still make the puzzle valid. For those unknown with nonograms, here's a link. A row is nothing more than a boolean array, where 'true' means it's marked, and 'false' would mean its' not.
The problem here lies within 'all possible mutations'. Let's look at an example. If a row would have the numbers 2, 1 and 3 next to it, the row would need at least 8 blocks of space (2+1+3, +2 for empty spaces necessary). So, if the row is 8 spaces long, there's no problem. However, if the row is larger than that, even by a small margin, it'd be very hard (NP hard even) to calculate all possible permutations. I cannot think of an algorithm which correctly does this. Can anyone help?
EDIT: It seems my question was unclear, so I'll try to clarify it a bit.
In the puzzle, let's assume we have a 1x4 puzzle, 1 row, 4 columns. Now let's look at the row:
2 1: _ _ _ _
Like this, the only possible answer is
2 1: X X _ X
But what if the puzzle was 1x8?
2 1: _ _ _ _ _ _ _ _
I'm looking for an algorithm that can find all permutations of such a line.
来源:https://stackoverflow.com/questions/25127342/calculation-of-all-possible-mutations-of-a-nonogram