Miscellaneous > Programming & Networking
Let's play a game, pals. Challenge 4.
TheQuirk:
You have a piece of math paper, 100 by 100 squares. On the paper, there are rectangles. The rectangles do not touch each other.
You have an array of 100 by 100, representing the piece of paper. For every square which is part of a rectangle, the value is 1. For every square which isn't, the value is 0. You have to figure out how many rectangles are drawn on the paper.
For example, the following array would represent a 10x10 piece of paper with two rectangles:
--- Code: ---
[[0000000000]
[0111100000]
[0111100000]
[0111100000]
[0000000000]
[0000000000]
[0000001100]
[0000001100]
[0000001100]
[0000000000]]
--- End code ---
Pathos:
Can rectangles overlap?
[[0000000000]
[0112222000]
[0112222000]
[0002222110]
[0002222110]
[0000000000]
[0000001100]
[0000001100]
[0000001100]
[0000000000]]
or
[[0000000000]
[0111111000]
[0111111000]
[0002222220]
[0002222220]
[0000000000]
[0000001100]
[0000001100]
[0000001100]
[0000000000]]
TheQuirk:
Nein.
Pathos:
So how should the examples I gave be interpreted.
TheQuirk:
It's not an issue; you won't be getting that sort of data. You'll only be getting non-touching, non-overlapping rectangles.
Navigation
[0] Message Index
[#] Next page
Go to full version