Skip to content

Instantly share code, notes, and snippets.

@jineshpaloor
Last active August 29, 2015 14:20
Show Gist options
  • Save jineshpaloor/7f9da803b54f0185867f to your computer and use it in GitHub Desktop.
Save jineshpaloor/7f9da803b54f0185867f to your computer and use it in GitHub Desktop.
Python script to create a unique string corresponding to a given input number.
import string
# number_letter_map = {0: 'A', 1: 'B', ... , 51: 'z'}
number_letter_map = dict(zip(range(52), string.letters))
def get_unique_string(number):
"""
Take a number as input and return a unique string corresponding to that number.
"""
letter_list = []
while(number > 0):
remainder = number % 52
letter = number_letter_map[remainder]
letter_list.append(letter)
number = number / 52
return ''.join(reversed(letter_list))
if __name__ == '__main__':
numbers = range(500000, 600000)
for n in numbers:
print n, '\t', get_unique_string(n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment