Advertisement
Guest User

Adventure Time

a guest
Jan 2nd, 2013
1,782
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.67 KB | None | 0 0
  1. from __future__ import print_function
  2.  
  3. """
  4. Adventure Time Comic #11 Secret Messages
  5. ========================================
  6. I had a hunch that the messages were letter values encoded in
  7. trinary but substituting BMO for 012 didn't work so I tried
  8. some more methods. Turns out it's OMB (BMO backwards) and
  9. the number -> letter substitution is backwards from Z too.
  10.  
  11. I won't ruin the surprise here but you can see the properly
  12. decoded messages (among the other wrong attempts) by running
  13. this Python script.
  14.  
  15. -blayde
  16. """
  17.  
  18. MESSAGES = [
  19.     'obo boo mbb obm bom bbm mmm bmo mbb obm bob omb mmo',
  20.     'omo bbm mbb obo omo boo bbm obo bbm obb bmo obo boo bmo obm bmo omo bmo mbb obb bmm mbb mmo obm obo obb omb bmb obo mbb mob mmo obm',
  21.     'mmb bmo omm bmo mmb mmo mbb mmo bmo mom obb mob obo mob bmb mob mmb mob omm bmo obb omo obb mbb obo bmo obm omb bmb bmb bmo obm obm',
  22.     'mmo bmo omo obm omb bbo obb mob omb obo mbb mmo bmo mbb mmo obm obo bbm mmb mmb bbm obo mbb mob mmo bmb mob mmm mom mmb bmo obo bmo',
  23. ]
  24.  
  25. # all permutations of 'bmo'
  26. REPLACEMENTS = ['bmo', 'bom', 'mob', 'mbo', 'omb', 'obm']
  27.  
  28. CONVERTERS = [
  29.     lambda x: chr(ord('a') + int(x, 3)),  # forwards from a
  30.     lambda x: chr(ord('z') - int(x, 3)),  # backwards from z
  31. ]
  32.  
  33. for message in MESSAGES:
  34.     attempts = [''] * (len(REPLACEMENTS) * len(CONVERTERS))
  35.     for letter in message.split(' '):
  36.         for i, r in enumerate(REPLACEMENTS):
  37.             replaced = letter.replace(r[0], '0').replace(r[1], '1').replace(r[2], '2')
  38.             for j, c in enumerate(CONVERTERS):
  39.                 attempts[i * len(CONVERTERS) + j] += c(replaced)
  40.     for attempt in attempts:
  41.         print(attempt)
  42.     print()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement