from __future__ import print_function

"""

Adventure Time Comic #11 Secret Messages

========================================

I had a hunch that the messages were letter values encoded in

trinary but substituting BMO for 012 didn't work so I tried

some more methods. Turns out it's OMB (BMO backwards) and

the number -> letter substitution is backwards from Z too.

I won't ruin the surprise here but you can see the properly

decoded messages (among the other wrong attempts) by running

this Python script.

-blayde

"""

MESSAGES = [

'obo boo mbb obm bom bbm mmm bmo mbb obm bob omb mmo' ,

'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' ,

'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' ,

'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' ,

]

# all permutations of 'bmo'

REPLACEMENTS = [ 'bmo' , 'bom' , 'mob' , 'mbo' , 'omb' , 'obm' ]

CONVERTERS = [

lambda x: chr ( ord ( 'a' ) + int ( x , 3 ) ) , # forwards from a

lambda x: chr ( ord ( 'z' ) - int ( x , 3 ) ) , # backwards from z

]

for message in MESSAGES:

attempts = [ '' ] * ( len ( REPLACEMENTS ) * len ( CONVERTERS ) )

for letter in message. split ( ' ' ) :

for i , r in enumerate ( REPLACEMENTS ) :

replaced = letter. replace ( r [ 0 ] , '0' ) . replace ( r [ 1 ] , '1' ) . replace ( r [ 2 ] , '2' )

for j , c in enumerate ( CONVERTERS ) :

attempts [ i * len ( CONVERTERS ) + j ] + = c ( replaced )

for attempt in attempts:

print ( attempt )