Created
October 30, 2008 03:40
-
-
Save zvoase/20907 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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