-
Notifications
You must be signed in to change notification settings - Fork 0
/
593.py
73 lines (61 loc) · 1.59 KB
/
593.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
class Solution(object):
def validSquare(self, p1, p2, p3, p4):
"""
:type p1: List[int]
:type p2: List[int]
:type p3: List[int]
:type p4: List[int]
:rtype: bool
"""
def distance_square(p1, p2):
return (p1[1] - p2[1]) ** 2 + (p1[0] - p2[0]) **2
# q=self.distance_square(p1,p2)
tri=[]
tri.append(distance_square(p1,p2))
tri.append(distance_square(p1,p3))
tri.append(distance_square(p1,p4))
tri.append(distance_square(p2,p3))
tri.append(distance_square(p2,p4))
tri.append(distance_square(p3,p4))
tri.sort()
if p1==p2 or p1==p3 or p1==p4:
return False
if tri[0]==tri[1]==tri[2]==tri[3] and tri[3]*2==tri[4]==tri[5]:
# if tri[0]+tri[1]==tri[2] and tri[0]==tri[1] and distance_square(p1,p2)==distance_square(p3,p4) and distance_square(p1,p3)==distance_square(p2,p4) and distance_square(p1,p4)==distance_square(p3,p2):
return True
else:
return False
# if distance_square(p1,p2)==distance_square(p3,p4) and distance_square(p1,p3)==distance_square(p2,p4) and distance_square(p1,p4)==distance_square(p3,p2) :
# return True
# else:
# return False
#%%
# p1 = [0,0]
# p2 = [1,1]
# p3 = [1,0]
# p4 = [0,1]
# p1 = [0,0]
# p2 = [1,1]
# p3 = [1,0]
# p4 = [0,12]
#
# p1 = [1,0]
# p2 = [-1,0]
# p3 = [0,1]
# p4 = [0,-1]
p1 = [0,1]
p2 = [1,2]
p3 = [0,2]
p4 = [0,0]
x=Solution
Solution.validSquare(x,p1,p2,p3,p4)
#%%
7%3
#%%
(-1)**2
#%%
a=[1,3,2]
b=[1,3,2]
a==b
#%%
1==1==1==1