Count Rectangles
Description:
Given a list/array of points on a quadratic grid, count the rectangles whose vertices are all in the given list.
The coordinates are non-negative integers (0 inclusive) bounded by 100. The axes of the coordinate system are orthogonal and equally scaled. The sides of a rectangle need not be horizontal or vertical.
Example 1:
Given the points
[(0, 0), (0, 1), (0, 2),
(1, 0), (1, 1), (1, 2),
(2, 0), (2, 1), (2, 2)]
There a 10 rectangles whose vertices are in this list. Nine rectagles have their sides aligned with the axes of the coordinate system, and the last rectangle is the one with coordinates (0, 1), (1, 0), (2, 1), (1, 2)
:
Example 2:
Given the points
[(1, 0), (4, 0),
(1, 1), (3, 1), (9, 1),
(0, 2), (4, 2), (5, 2), (6, 2), (9, 2),
(2, 3), (5, 3),
(1, 4), (2, 4), (4, 4), (5, 4), (9, 4)]
There are 12 rectangles whose vertices are in the given list, as shown in the figure:
The vertices of these rectangles are:
((3, 1), (1, 0), (0, 2), (2, 3))
((0, 2), (1, 0), (5, 2), (4, 4))
((0, 2), (4, 0), (5, 2), (1, 4))
((1, 0), (4, 0), (4, 4), (1, 4))
((4, 0), (3, 1), (5, 3), (6, 2))
((4, 0), (1, 1), (2, 4), (5, 3))
((1, 1), (9, 1), (9, 4), (1, 4))
((3, 1), (5, 2), (4, 4), (2, 3))
((4, 2), (5, 2), (5, 4), (4, 4))
((4, 2), (9, 2), (9, 4), (4, 4))
((5, 2), (9, 2), (9, 4), (5, 4))
((5, 3), (2, 3), (2, 4), (5, 4))
The most complex tests will randomly select approximately 15% of the points in a 50-by-100 grid. The result will typically be in the thousands.
Similar Kata:
Stats:
Created | Nov 28, 2019 |
Published | Nov 28, 2019 |
Warriors Trained | 280 |
Total Skips | 103 |
Total Code Submissions | 144 |
Total Times Completed | 26 |
Python Completions | 26 |
Total Stars | 14 |
% of votes with a positive feedback rating | 94% of 8 |
Total "Very Satisfied" Votes | 7 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 6 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |