Skip to content

Instantly share code, notes, and snippets.

@madranet
Created December 18, 2016 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madranet/37dbc8544f5c59e4a3896396e0677680 to your computer and use it in GitHub Desktop.
Save madranet/37dbc8544f5c59e4a3896396e0677680 to your computer and use it in GitHub Desktop.
print("\n===========================================================")
print("VERTICAL MESSAGE DECODING:")
print("===========================================================\n")
esperanto = ""
for section in vertmessage:
#take 3 letters at a time and convert to morse
#join 3 morse letters together to create braille letter
#if the 'section' consists of 3 spaces, then interpret it s a single space between words'
#yes. I know this is a bit clunky but it doesn't need importing regex module!
if section == " ":
esperanto += " "
# 'section' wasn't a triple space, so look it up as a braille letter...
# using the previous method
else:
brailleletter = (morse[section[0]]+morse[section[1]]+morse[section[2]])
#lookup braille letter
try:
#if it exists, add it to the esperanto string
esperanto += (list(braille.keys())[list(braille.values()).index(brailleletter)])
#if it doesn't exist, print '?'
except:
esperanto += "?"
# print the constructed esperanto string
print(esperanto)
print("\n===========================================================\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment