Created
May 13, 2009 16:09
-
-
Save tantalor/111103 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 bin(x, k=0): | |
d = {0:'000', 1:'001', 2:'010', 3:'011', 4:'100', 5:'101', 6:'110', 7:'111'} | |
return ''.join([d[int(dig)] for dig in oct(x)]).lstrip('0').zfill(k) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment