-
Notifications
You must be signed in to change notification settings - Fork 1
/
dis.py
58 lines (29 loc) · 747 Bytes
/
dis.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
from operator import itemgetter
def calc(title):
f = open("values", "r")
val1 = []
k = []
for line in f:
a = line.split()
Title = ' '.join(a[:-3])
if Title == title:
val3 = a[-3:]
val1 = [float(i) for i in val3]
break
ans = []
for line in f:
a = line.split()
Title = ' '.join(a[:-3])
val4 = a[-3:]
val = [float(i) for i in val4]
if Title != title:
dis = pow(pow(val[0] - val1[0], 2) + pow(val[1] - val1[1], 2) + pow(val[2] - val1[2], 2), 0.5)
ans.append([Title, dis])
sorted(ans, key=itemgetter(1))
#for i in xrange(5):
# print ans[i]
return ans
#if __name__ == "__main__":
#calc("Enter Sandman Lyrics - Metallica")
#return 'BLAH'
# calc("Enter Sandman Lyrics - Metallica")