Given a problem identical to this: Tricky Rectangle Problem. If we were to add more yellow squares is it possible to calculate the total number of possible rectangles that do not contain any yellow squares efficiently? It seems if you scale the solution in the given link you will have to consider every possible combination of yellow squares.
Asked
Active
Viewed 76 times
1
-
Clarification requested: must each side of a given rectangle be either horizontal or vertical? That is, what about a rectangle whose 4 corners are each a grid point, but that doesn't have vertical/horizontal sides? – user2661923 Feb 27 '21 at 04:55
-
@user2661923 Each rectangle must be either horizontal or vertical. – Wesley Burrns Feb 27 '21 at 05:02
-
1I assume squares are allowed. Calculate all possible rectangles. Calculate all rectangles that include a yellow square. Multiply by two and subtract from the above. Add all the cases that include both yellow squares. – Moti Feb 27 '21 at 05:21
-
2For your case @stevengregory's ingenious method becomes efficient. Do you see the patterns in his solution? – cosmo5 Feb 27 '21 at 05:54
-
@cosmo5 I see that it is mirrored over the diagonal, but I don't see any other pattens that would make it efficient. Would you have to manually calculate the number of rectangles for each box? – Wesley Burrns Feb 27 '21 at 06:31
-
@Moti I don't believe this solution will scale if you add a third or fourth yellow square because then you will have to account for the numerous combinations. I originally considered this, but it doesn't seem to be very efficient. – Wesley Burrns Feb 27 '21 at 06:32
-
1I think that once you calculate several cases for yellow squares - the algorithm to calculate the required rectangles will be nicely scaled - like the probability calculation of multiple overlapping events. – Moti Feb 27 '21 at 18:36