Decode the Morse code

Messages
1,679
Reaction score
288
Website
tehadm.ru
По заданию требуется декодировать код морзе в текст...
 
C-like:
package kata

import "strings"

func DecodeMorse(morseCode string) string {
    messageEncrypt := strings.ReplaceAll(morseCode, "   ", " * ")
    messageEncryptSlice := strings.Split(messageEncrypt, " ")   
    messageDecrypt := ""
    for _, val := range messageEncryptSlice {
        if val == "*" {
            messageDecrypt += " "
        } else {
            messageDecrypt += MORSE_CODE[val]
        }
    }
    return strings.TrimSpace(messageDecrypt)
}
 
Back
Top