-
-
Save joncle/6b8175ea6f34489d4187 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 num_to_base(num, base='ab'): | |
if num == 0: | |
return base[0] | |
res = [] | |
while num: | |
num, m = divmod(num, len(base)) | |
res.append(base[m]) | |
return ''.join(res) | |
for i in xrange(5): | |
print num_to_base(i), | |
# a b ab bb aab | |
for i in xrange(4, 10): | |
print num_to_base(i), | |
# aab bab abb bbb aaab baab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment