Skip to content

Instantly share code, notes, and snippets.

@changlinli
Created January 25, 2014 06:30
Show Gist options
  • Save changlinli/8612594 to your computer and use it in GitHub Desktop.
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.
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