Last active
December 16, 2015 12:09
-
-
Save AKST/5432352 to your computer and use it in GitHub Desktop.
Reverse Binary with stdin
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 reverse_bin (num): | |
reversed = 0 | |
while num != 0: | |
reversed = (reversed << 1) | (num & 1) | |
num >>= 1 | |
return reversed | |
if __name__ == "__main__": | |
print(reverse_bin(int(input()))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment