Skip to content

Instantly share code, notes, and snippets.

@emberian
Forked from martianman/gist:5159740
Last active December 14, 2015 22:39
Show Gist options
  • Save emberian/5159759 to your computer and use it in GitHub Desktop.
Save emberian/5159759 to your computer and use it in GitHub Desktop.
a = bin(999999999)[2:]
temp = []
for i, v in enumerate(a):
if v == '1':
temp.append(len(a) - i)
print a
print temp
# 111011100110101100100111111111
# [30, 29, 28, 26, 25, 24, 21, 20, 18, 16, 15, 12, 9, 8, 7, 6, 5, 4, 3, 2, 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment