in reply to Tricky math problem ...
I can see this problem getting more complex. Let us try to simplify the problem right down with the aim of expanding the options in the future. I'm trying to turn it into an academic exercise.
ok. Imagine we have a square that is 2 by 2. How many options. For (row1pos1, row1pos2, row2pos1, row2pos2). We have (1,1,1,1),(0,1,1,1), (1,0,1,1), (1,1,0,1), (1,1,1,0), (0,0,1,1), (1,0,0,1), (1,1,0,0), (0,0,0,1), (1,0,0,0), (0,1,0,1), (1,0,1,0), (0,0,0,0), there is also, (0,1,0,0), (0,0,1,0) , (0,1,1,0) There are 16 outcomes, right? There are 4 cell, 2 possibilities for each cell.
With 1 cell there would be 2 options
2 cells, 4 combinations.
3 cells, 8 combinations. (1,1,1), (0,1,1), (1,0,1), (1,1,0), (0,0,1), (1,0,0), (0,1,0), (0,0,0)
4 cells, 16 outcomes
The number of outcomes is the number of options to the power of the number of cells. The forth case is 2 x 2 x 2 x 2 = 16.
In our case there is 12 x 12 cells. This is 144 cells. 2 to the power of 144 is 2.2300745e+43. That is a big number.
Without complicating things, if this was a DNA sequence there would be 4 options rather than two. 4 to the power of 144 is 4.9732324e+86 .... wooh
In the case presented here. There are multiple small squares. However, in subdividing the squares into subsquares we are creating virtual presence of stars '*'s. You see how I am presenting all this. Yeah. We haven't done the calculation. But you can see that there would be a lot of options.
Therefore we really need to understand more about the problem. It would require machine learning and decision trees. Not Perl's strongest basket. I would love and be loved to see Perl move more in that direction because of the fantastic community it has.