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 4%
Shanethegamer
#2
102 c.
Top 7%
tree
#3
113 c.
Top 11%
AlephSquirrel
#4
116 c.
Top 14%
helbling
#5
123 c.
Top 18%
Lv0Sys
#6
124 c.
Top 21%
sean
#7
130 c.
Top 25%
Europe2048
#8
133 c.
Top 29%
Natanaelel
#9
136 c.
Top 32%
cers
#10
139 c.
Top 36%
val
#11
140 c.
Top 39%
voytxt
#12
145 c.
Top 43%
Thomasdcrt
#13
150 c.
Top 46%
scpchicken
#14
162 c.
Top 54%
Alex
SephQ
#15
166 c.
Top 57%
Rag
#16
170 c.
Top 61%
davyboyh
#17
172 c.
Top 64%
maximec-indy
#18
174 c.
Top 68%
Pascal
#19
182 c.
Top 71%
XenThe
#20
186 c.
Top 75%
Mif712
#21
195 c.
Top 79%
ComputerKWasTaken
#22
200 c.
Top 82%
thaispalmer
#23
219 c.
Top 86%
KrausRaus
#24
258 c.
Top 89%
madeforlosers
#25
427 c.
Top 93%
Luke
#26
593 c.
Top 96%
jules
#27
606 c.
Top 100%
Arnaud