Created
December 1, 2013 10:52
-
-
Save inky/7731934 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 python | |
| HUMAN = 'beep boop' | |
| ROBOT = '011000100110010101100101011100000010000001100010011011110110111101110000' | |
| def splitbin(s): | |
| for i in range(0, len(s), 8): | |
| yield s[i : i + 8] | |
| assert ROBOT == ''.join(bin(ord(c))[2:].zfill(8) for c in HUMAN) | |
| assert HUMAN == ''.join(chr(int(b, 2)) for b in splitbin(ROBOT)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment