-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetLetterNumber.py
More file actions
executable file
·78 lines (61 loc) · 1.93 KB
/
Copy pathgetLetterNumber.py
File metadata and controls
executable file
·78 lines (61 loc) · 1.93 KB
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
74
75
76
77
78
#!/usr/bin/python3.1
def getNumberLetter(let1, num1, let2, num2, samples=1):
if samples <= 0:
return
let1Val = ord(let1.upper())-ord('A')
let2Val = ord(let2.upper())-ord('A')
frame1 = let1Val+(num1 * 26)
frame2 = let2Val+(num2 * 26)
frameaverage = (frame1+frame2) // 2
ret = divmod(frameaverage, 26)
ret = (chr(ret[1]+ord('A')), ret[0])
samples -= 1
if samples > 0:
result1 = getNumberLetter(let1, num1, ret[0], ret[1], samples)
result2 = ret
result3 = getNumberLetter(ret[0], ret[1], let2, num2, samples)
ret = ()
if len(result1) > 2:
ret1 = ()
for i in result1:
ret1 += (i,)
else:
ret1 = (result1,)
ret2 = result2
if len(result3) > 2:
ret3 = ()
for i in result3:
ret3 += (i,)
else:
ret3 = (result3,)
ret = ret1+(ret2,)+ret3
return ret
if __name__ == "__main__":
argList = [["letter 1", ""], ["number 1", 0], ["letter 2", ""], ["number 2", 0], ["sample count", 2]]
for (argN, arg) in enumerate(argList):
success = 0
newArg = None
while not success:
success = 1
newArg = input("%s? - " % arg[0])
if type(arg[1]) == type(''):
from string import ascii_letters
if len(newArg) != 1:
success = 0
print("letter must be one character")
elif newArg not in ascii_letters:
success = 0
print("letter must be an ascii letter")
if type(arg[1]) == type(0):
try:
newArg = int(newArg)
except:
success = 0
print("number must be an integer")
else:
if newArg < 1:
success = 0
print("number must be higher than 0")
argList[argN][1] = newArg
argList2 = [arg[1] for arg in argList]
print(((argList2[0], argList2[1]),) + getNumberLetter(*argList2) + ((argList2[2], argList2[3]),))