Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # num2alpha.py -- demo vs infiniteshakespearianmonkey ;)
- subatomic = 'abcdefghijklmnopqrstuvwxyz_' # "_" represents other key elements
- def num2alpha(num):
- letters = ''
- while num:
- mod = (num - 1) % 27 #26
- letters += subatomic[mod] # or... chr(mod + 65).lower()
- num = (num - 1) // 27 #26
- return ''.join(reversed(letters))
- #
- result = ''
- count = 1
- while result != 'bye' and len(result) < 19: # or True (as pseudo infinite)
- result = num2alpha(count)
- print result,
- count += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement