Created
April 5, 2017 13:11
-
-
Save micahhausler/3c177c19c30d04795c3a68062440659b to your computer and use it in GitHub Desktop.
Morse Code Decrypter
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
# See https://itunes.apple.com/us/app/medium/id828256236?mt=8, version 2.48 | |
morse = { | |
".-": "A", "-...": "B", "-.-.": "C", "-..": "D", ".": "E", "..-.": "F", "--.": "G", "....": "H", | |
"..": "I", ".---": "J", "-.-": "K", ".-..": "L", "--": "M", "-.": "N", "---": "O", ".--.": "P", | |
"--.-": "Q", ".-.": "R", "...": "S", "-": "T", "..-": "U", "...-": "V", ".--": "W", "-..-": "X", | |
"-.--": "Y", "--..": "Z", "-----": "0", ".----": "1", "..---": "2", "...--": "3", "....-": "4", | |
".....": "5", "-....": "6", "--...": "7", "---..": "8", "----.": "9", "/": " ", ".-.-.-": ".", | |
".----.": "'", "--..--": ","} | |
text = ( | |
'- .... .. ... / ..- .--. -.. .- - . / -- .- .. -. .-.. -.-- / -.-. --- -. - .- .. -. ... /' | |
' ... --- -- . / ..-. . .- - ..- .-. . / . -. .... .- -. -.-. . -- . -. - ... / .- -. -.. /' | |
' ..-. .. -..- . ... / ..-. --- .-. / --- ..- .-. / -. --- - / ... --- / ... . -.-. .-. . - /' | |
' -- . -- -... . .-. ... .... .. .--. .-.-.- / .-- . / .--. ..- - / .. - / .. -. /' | |
' -- --- .-. ... . / -.-. --- -.. . / -... . -.-. .- ..- ... . / -- . -- -... . .-. ... .... .. .--. /' | |
' .... .- ... -. .----. - / -... . . -. / .-- .. -.. . .-.. -.-- / .-. . .-.. . .- ... . -.. /' | |
' -.-- . - .-.-.- / -- . -.. .. ..- -- / -- . -- -... . .-. ... / .-- .. .-.. .-.. / --. . - /' | |
' - .... . / .-. . -.. . ... .. --. -. . -.. / .... --- -- . .--. .- --. . /' | |
' .-.. .- -.-- --- ..- - / .- -. -.. / .- -.. -.. .. - .. --- -. .- .-.. /' | |
' -- . -- -... . .-. ... .... .. .--. / -... .- -.. --. .. -. --. / .- - /' | |
' -- --- .-. . / .--. .-.. .- -.-. . ... / .. -. / - .... . / .- .--. .--. --..-- /' | |
' .--. .-.. ..- ... / .. - / ..-. .. -..- . ... / .- / -... ..- --. / .- ..-. ..-. . -.-. - .. -. --. /' | |
' - .... . / -. . .-- / .-. . .- -.. .. -. --. / .-.. .. ... - / - --- --- .-.. .-.-.- /' | |
' .- -.. -.. .. - .. --- -. .- .-.. .-.. -.-- / - .... . .-. . / .- .-. . / ... --- -- . /' | |
' -... ..- --. / ..-. .. -..- . ... / .- -. -.. / .--. . .-. ..-. --- .-. -- .- -. -.-. . /' | |
' . -. .... .- -. -.-. . -- . -. - ... / - --- / .. -- .--. .-. --- ...- . / - .... . /' | |
' --- ...- . .-. .- .-.. .-.. / .... . .- .-.. - .... / --- ..-. / - .... . / .- .--. .--. .-.-.- /' | |
' -... . / ... ..- .-. . / - --- / -.. .-. .. -. -.- / -.-- --- ..- .-. / --- ...- .- .-.. - .. -. . .-.-.-' | |
) | |
print(''.join([morse[w] for w in text.split(' ')])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment