Skip to content

Commit

Permalink
Rectangle_Mania
Browse files Browse the repository at this point in the history
  • Loading branch information
Partho Biswas committed May 3, 2020
1 parent 090c984 commit 8a04698
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ BFS, DFS, Dijkstra, Floyd–Warshall, Bellman-Ford, Kruskal, Prim's, Minimum Spa
|04| [Depth_First_Search](algoexpert.io/questions/Depth-first_Search.md) | [Python](algoexpert.io/python/Depth_First_Search.py)|
|05| [Breadth_First_Search](algoexpert.io/questions/Breadth-first_Search.md) | [Python](algoexpert.io/python/Breadth_First_Search.py)|
|06| [Boggle_Board](algoexpert.io/questions/Boggle_Board.md) | [Python](algoexpert.io/python/Boggle_Board.py) |
|07| [Rectangle_Mania](algoexpert.io/questions/Rectangle_Mania.md) | [Python](algoexpert.io/python/Rectangle_Mania.py) |

</p>
</details>
Expand Down
21 changes: 21 additions & 0 deletions algoexpert.io/python/Rectangle_Mania.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
x1,y1
x2,y2
"""


def rectangleMania(coords):
coordSet = set([(coord[0], coord[1]) for coord in coords])
rectangleCount = 0
for i in range(len(coords)):
for j in range(len(coords)):
coordOne = coords[i]
coordTwo = coords[j]
if coordOne == coordTwo:
continue
if (coordOne[0] > coordTwo[0]) and (coordOne[1] > coordTwo[1]):
if (coordOne[0], coordTwo[1]) in coordSet and (coordTwo[0], coordOne[1]) in coordSet:
rectangleCount += 1
return rectangleCount

13 changes: 13 additions & 0 deletions algoexpert.io/questions/Rectangle_Mania.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Rectangle_Mania

#### Problem Statement


![alt text](Rectangle_Mania.png "Rectangle_Mania")



#### Solution

Check this [Python](../python/Rectangle_Mania.py) code.

Binary file added algoexpert.io/questions/Rectangle_Mania.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8a04698

Please sign in to comment.