-
Notifications
You must be signed in to change notification settings - Fork 0
/
compattable.py
executable file
·58 lines (49 loc) · 1.48 KB
/
compattable.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
#!/usr/bin/env python
# Score-based network analysis of biorhythms. Higher scores mean more compatibility.
# (Matching primary cycles net two points. 50%-65% compatibility is considered neutral.)
# Usage:
# python2 compattable.py | sort -g
from math import cos, pi
from datetime import date
# "Star Trek: The Next Generation" male cast example data:
pers=(
((1940,7,13), "Patrick Stewart"),
((1949,2,2), "Brent Spiner"),
((1952,8,19), "Jonathan Frakes"),
((1957,2,16), "LeVar Burton"),
((1952,12,9), "Michael Dorn"),
)
nn = ("P","E","I")
def f(a):
if a < -3:
return "(-)" # bad compatibility
elif a > 3:
return "(+)" # good " "
else:
return "(0)" # neutral
for n1, d1 in enumerate(pers):
for n2, d2 in enumerate(pers):
if n1 >= n2: continue
yy,mm,dd = d1[0]
yy2,mm2,dd2 = d2[0]
t1 = date(yy,mm,dd).toordinal()
t2 = date(yy2,mm2,dd2).toordinal()
lag = abs(t2 - t1)
score = 0
mat = ''
for p in range(0,7):
ld = 23 + 5 * p
l_lag = lag % ld
qq = 100. * abs(cos(pi * l_lag / ld))
if qq < 50:
if p < 3:
score -= 2
else:
score -= 1
elif qq > 65:
if p < 3:
score += 2
mat += nn[p]
else:
score += 1
print (score, d1[1],d2[1], f(score),mat)