Created
January 25, 2014 06:30
-
-
Save changlinli/8612594 to your computer and use it in GitHub Desktop.
A short and dirty Python script to decode MIT's blog post written in binary.
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 group_by_n(line, n): | |
if line == "": | |
return [] | |
elif line[0] == " ": | |
return [" "] + group_by_n(line[1:], n) | |
else: | |
return [line[:n]] + group_by_n(line[n:], n) | |
with open("post.txt") as fp: | |
final_string = "" | |
for line in fp: | |
groups = group_by_n(line, 8) | |
for char in groups: | |
if char != " " and char != "\n": | |
final_string += chr(int(char, 2)) | |
else: | |
final_string += char | |
print final_string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment