Skip to content

Instantly share code, notes, and snippets.

@flegoff
Created September 30, 2010 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flegoff/604570 to your computer and use it in GitHub Desktop.
Save flegoff/604570 to your computer and use it in GitHub Desktop.
A base26 (A->Z) looping counter
## A base26 (A->Z) looping counter
#
# AAA, AAB, AAC.... ZZY, ZZZ, AAA
l_input = 'AAA'
l_output = ''
ret = 1
for e in l_input[::-1]:
new = (ord(e) - 65 + ret) % 26
ret = (not new and ret) and 1 or 0
l_output += chr(new + 65)
l_output = l_output[::-1]
print l_output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment