Link Search Menu Expand Document

Morse Code

Encode a given string consisting of lowercase letters and spaces into a Morse code using the following convention:

  • . - dit (short mark)
  • - - dah (long mark)
  • “ ” (1 space)- short gap (between letters)
  • “   ” (3 spaces) - medium gap (between words)

E.g. for the following input text: what hath god wrought the ouput should be:

”.−− …. .− −   …. .− − ….   −−. −−− −..   .−− .−. −−− ..− −−. …. − ”

** Bonus Points: Write a program to decode a string in Morse code back to plain text. (Use the string.Split() method to split the encoded string into chunks).