Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
You can’t perform that action at this time.