-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreturn-codes.py
More file actions
29 lines (24 loc) · 784 Bytes
/
return-codes.py
File metadata and controls
29 lines (24 loc) · 784 Bytes
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
def get_alphabet(number):
return chr(number+96)
def all_codes(number):
if number == 0:
return [""]
#calculation of 2 right most digits
reminder = number%100
output_100 = list()
if reminder <= 26 and number> 9:
output_100 = all_codes(number//100)
alphabet = get_alphabet(reminder)
for index, elem in enumerate(output_100):
output_100[index] = elem + alphabet
#calculation of right most digit
reminder = number%10
output_10 = all_codes(number//10)
alphabet = get_alphabet(reminder)
for index,elem in enumerate(output_10):
output_10[index] = elem + alphabet
output = list()
output.extend(output_10)
output.extend(output_100)
return output
print(all_codes(1145))