Skip to content

Instantly share code, notes, and snippets.

@zvoase
Created October 30, 2008 03:40
Show Gist options
  • Save zvoase/20907 to your computer and use it in GitHub Desktop.
Save zvoase/20907 to your computer and use it in GitHub Desktop.
def number_to_string(number, words):
list_out = []
if not number:
return words[0] # Because 0 is '0', not ''.
while number:
list_out = [number % len(words)] + list_out
number = number // len(words)
return ''.join(words[n] for n in list_out)
def number_to_zpadded_string(number, length=32):
return number_to_string(number, 'abcdefghijklmnopqrstuvwxy').ljust(
length, 'z')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment