All values here are real numbers with up to two floating point digits.
Suppose we have a rectangular area, 100.0
by 75.0
.
Then you are given a set of rectangles. How can I check whether these rectangles, united, cover the entire area?
If we have
(0,0,50,75)
clearly this does not happen since it only covers half the area. If we have
(0,0,50,75)
(50,0,50,75)
Then this does work, since both rectangles will effectively cover the whole (100,75)
.
What have I tried
I attempted (didn't work) to make a multi-dimensional array of booleans:
bool area[10000][7500];
These are the dimensions of the area, multiplied by 100 so that I don't have to deal with the floating points. Then I just iterate each of my rectangles (their values also multiplied by 100), and for each "pixel" in them, I turn the boolean to true
.
Ultimately, I check if all booleans in the area are true
.
This proved to be very dumb. Can you help me find a better way to do this?