Skip to content

Commit 1adc02c

Browse files
author
Partho Biswas
committed
Rectangle_Mania
1 parent 812e404 commit 1adc02c

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,7 @@ BFS, DFS, Dijkstra, Floyd–Warshall, Bellman-Ford, Kruskal, Prim's, Minimum Spa
858858
|04| [Depth_First_Search](algoexpert.io/questions/Depth-first_Search.md) | [Python](algoexpert.io/python/Depth_First_Search.py)|
859859
|05| [Breadth_First_Search](algoexpert.io/questions/Breadth-first_Search.md) | [Python](algoexpert.io/python/Breadth_First_Search.py)|
860860
|06| [Boggle_Board](algoexpert.io/questions/Boggle_Board.md) | [Python](algoexpert.io/python/Boggle_Board.py) |
861+
|07| [Rectangle_Mania](algoexpert.io/questions/Rectangle_Mania.md) | [Python](algoexpert.io/python/Rectangle_Mania.py) |
861862

862863
</p>
863864
</details>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""
2+
x1,y1
3+
4+
x2,y2
5+
"""
6+
7+
8+
def rectangleMania(coords):
9+
coordSet = set([(coord[0], coord[1]) for coord in coords])
10+
rectangleCount = 0
11+
for i in range(len(coords)):
12+
for j in range(len(coords)):
13+
coordOne = coords[i]
14+
coordTwo = coords[j]
15+
if coordOne == coordTwo:
16+
continue
17+
if (coordOne[0] > coordTwo[0]) and (coordOne[1] > coordTwo[1]):
18+
if (coordOne[0], coordTwo[1]) in coordSet and (coordTwo[0], coordOne[1]) in coordSet:
19+
rectangleCount += 1
20+
return rectangleCount
21+

0 commit comments

Comments
 (0)