Skip to content

Instantly share code, notes, and snippets.

@dylanchapell
Created November 10, 2022 21:27
Show Gist options
  • Save dylanchapell/3331aa200a28bbf6561d3be26a82ab63 to your computer and use it in GitHub Desktop.
Save dylanchapell/3331aa200a28bbf6561d3be26a82ab63 to your computer and use it in GitHub Desktop.
Decode number codes to letters using encoding from A Friendly Introduction to Number Theory textbook, with a=11 and z=36
import sys
letterdict = {
11:'a',
12:'b',
13:'c',
14:'d',
15:'e',
16:'f',
17:'g',
18:'h',
19:'i',
20:'j',
21:'k',
22:'l',
23:'m',
24:'n',
25:'o',
26:'p',
27:'q',
28:'r',
29:'s',
30:'t',
31:'u',
32:'v',
33:'w',
34:'x',
35:'y',
36:'z'
}
print("Arguments count: "+str(len(sys.argv)))
print("Please provide arguments in even digit numbers")
for i, arg in enumerate(sys.argv):
if i>0:
#print("Argument "+str(i)+": "+arg)
for i in range(int(len(arg)/2)):
c1 = arg[2*i]
c2 = arg[2*i+1]
##print("Decoding: "+c1+c2)
num = (int(c1)*10)+int(c2)
print(str(letterdict[num]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment