Originally Posted by

**Salem**
Well my previous simplistic algorithm doesn't work in all cases.

But given this,

**1 0 - -**

- - - -

- - - -

- - - -

I would compute the min and max values that each quadrant could contain.

So red has a min of 1 and a max of 3

All the others have a min of 0 and a max of 4

The number of 1's you need to put in red and cyan quadrants is

min(max(red),max(cyan))

Which in this example is 3.

The number of 1's you need to put in green and blue quadrants is

min(max(green),max(blue))

Which in this example is 4.