Created
February 14, 2020 19:10
-
-
Save jordanmack/08a2dc513ca00abc779b7812c73f9bfd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python3 | |
def format_binary(i): | |
s = bin(i) | |
s = s.replace("0b", "") | |
return s | |
def gray_code(n): | |
return n ^ (n >> 1) | |
def print_binary_gray_code(i): | |
b = format_binary(i) | |
g = format_binary(gray_code(i)) | |
print(f"""{b} {g}""") | |
if __name__ == "__main__": | |
print_binary_gray_code(187836561118445077) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment