Skip to content

Instantly share code, notes, and snippets.

@six519
Created July 9, 2013 16:02
Show Gist options
  • Save six519/5958606 to your computer and use it in GitHub Desktop.
Save six519/5958606 to your computer and use it in GitHub Desktop.
Reverse Binary (Spotify Puzzle in Python)
#!/usr/bin/env python
if __name__ == "__main__":
decimalNumber = raw_input()
try:
decimalNumber = int(decimalNumber)
if decimalNumber >= 1 and decimalNumber <= 1000000000:
print "%s" % int(str(bin(int(decimalNumber))).replace('0b','')[::-1],2)
else:
raise
except Exception:
print "Invalid input"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment