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 9%
tree
#3
113 c.
Top 13%
AlephSquirrel
#4
116 c.
Top 17%
helbling
#5
124 c.
Top 22%
sean
#6
133 c.
Top 26%
Natanaelel
#7
136 c.
Top 30%
cers
#8
139 c.
Top 35%
val
#9
140 c.
Top 39%
voytxt
#10
145 c.
Top 43%
Thomasdcrt
#11
150 c.
Top 48%
scpchicken
#12
162 c.
Top 57%
Alex
SephQ
#13
170 c.
Top 61%
davyboyh
#14
172 c.
Top 65%
maximec-indy
#15
174 c.
Top 70%
Pascal
#16
186 c.
Top 74%
Mif712
#17
195 c.
Top 78%
ComputerKWasTaken
#18
200 c.
Top 83%
thaispalmer
#19
219 c.
Top 87%
KrausRaus
#20
258 c.
Top 91%
madeforlosers
#21
593 c.
Top 96%
jules
#22
606 c.
Top 100%
Arnaud