-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnumerology.py
executable file
·72 lines (65 loc) · 1.48 KB
/
numerology.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
#!/usr/bin/python2.7
"""Pythagorean numerology chart
1 2 3 4 5 6 7 8 9
-----------------
A B C D E F G H I
J K L M N O P Q R
S T U V W X Y Z
"""
import sys
class Numerology:
def __init__(self, s):
self._s = s
self._l = list(self._s.replace(' ', '').strip().lower())
self._dicts = {
'pythagorean': {
'a': 1,
'b': 2,
'c': 3,
'd': 4,
'e': 5,
'f': 6,
'g': 7,
'h': 8,
'i': 9,
'j': 1,
'k': 2,
'l': 3,
'm': 4,
'n': 5,
'o': 6,
'p': 7,
'q': 8,
'r': 9,
's': 1,
't': 2,
'u': 3,
'v': 4,
'w': 5,
'x': 6,
'y': 7,
'z': 8
}
}
def pythagorean(self):
d = self._dicts['pythagorean']
s = ''
k = 0
for c in self._l:
i = d[c]
s += str(i)
k += i
return {
'sum': k,
'string': s
}
def main():
a = sys.argv
if (len(a) < 2):
print ('Usage: ./numerology.py billgates')
return
n = Numerology(sys.argv[-1])
r = n.pythagorean()
print ('Pythagorean: {}'.format(r['sum']))
if __name__ == "__main__":
main()