Morse Code Translator

Translate a string into morse code.

Easy1/7/2024

Problem statement

Your task is to write a program that takes a string as input and translates it into its equivalent in international Morse code. The input will be a string of lowercase space-separated words where each word consists of nothing but the letters a-z. Add spaces between the words but not between the letters of a word in morse code. Here is the alphabet in morse code:

a: .-      g: --.     m: --      s: ...     y: -.--  
b: -...    h: ....    n: -.      t: -       z: --..  
c: -.-.    i: ..      o: ---     u: ..-     
d: -..     j: .---    p: .--.    v: ...-    
e: .       k: -.-     q: --.-    w: .--     
f: ..-.    l: .-..    r: .-.     x: -..-    

For example, the string

lorem ipsum

should be translated to

.-..---.-..-- ...--......---

Problem leaderboard

#
Size
%
Users
#1
101 c.
Top 8%
Shanethegamer
#2
102 c.
Top 15%
tree
#3
113 c.
Top 23%
AlephSquirrel
#4
124 c.
Top 31%
sean
#5
133 c.
Top 38%
Natanaelel
#6
139 c.
Top 46%
val
#7
145 c.
Top 54%
Thomasdcrt
#8
146 c.
Top 62%
voytxt
#9
150 c.
Top 69%
scpchicken
#10
170 c.
Top 77%
davyboyh
#11
172 c.
Top 85%
maximec-indy
#12
174 c.
Top 92%
Pascal
#13
219 c.
Top 100%
KrausRaus