Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Morse Decoder by vit.aborigen
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',
}
def morse_decoder(code):
result = ''
for word in code.split(' '):
for char in word.split():
result += MORSE[char]
result += ' '
return (result[0].upper() + result[1:-1]) if result[0].isalpha() else result[:-1]
Nov. 11, 2018
Comments: