Skip to content

Commit 9414061

Browse files
authored
Update valid-square.py
1 parent b17710d commit 9414061

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Python/valid-square.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def validSquare(self, p1, p2, p3, p4):
2828
def dist(p1, p2):
2929
return (p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2
3030

31-
counter = collections.Counter([dist(p1, p2), dist(p1, p3),\
32-
dist(p1, p4), dist(p2, p3),\
33-
dist(p2, p4), dist(p3, p4)])
34-
return counter[0] == 0 and len(counter) == 2
31+
lookup = set([dist(p1, p2), dist(p1, p3),\
32+
dist(p1, p4), dist(p2, p3),\
33+
dist(p2, p4), dist(p3, p4)])
34+
return 0 not in lookup and len(lookup) == 2

0 commit comments

Comments
 (0)