String to Morse Translator | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

String to Morse Translator

Can I make this with an algorhthm instead of a switch? I thought of two arrays and some loops but my logic isn't that good to finish it :D https://code.sololearn.com/cnGmc5KRo43X/?ref=app

30th Aug 2017, 8:14 AM
Gabriel Popa
Gabriel Popa - avatar
11 Answers
+ 2
If you can find a pattern in the Morse Code that would make things a lot easier
30th Aug 2017, 8:29 AM
Limitless
Limitless - avatar
+ 2
hmm maybe this site can help http://frank.vanhaste.com/morse.html But as it looks like, you might need to do some hard textual coding anyway My guess is that the Switch is thus far the best method
30th Aug 2017, 8:44 AM
Limitless
Limitless - avatar
+ 1
Thank, you limitless! I found one at the numbers but it's harder with the letters, so... :) Great idea though
30th Aug 2017, 8:30 AM
Gabriel Popa
Gabriel Popa - avatar
+ 1
hmm maybe this site can help http://frank.vanhaste.com/morse.html But as it looks like, you might need to do some hard textual coding anyway
30th Aug 2017, 8:44 AM
Limitless
Limitless - avatar
+ 1
ysraelcon so far so good. A multi-dimensional array is great, but what if the user inserts an uppercase letter?
30th Aug 2017, 3:19 PM
Gabriel Popa
Gabriel Popa - avatar
+ 1
ready, case insensitive enabled 👌
30th Aug 2017, 3:44 PM
ysraelcon
ysraelcon - avatar
+ 1
u can use a string and an array the string contains characters, and the array contains Morse code , the index of each character in the string must correspond to the index of its Morse code in the array , the following code illustrates this for three characters : abc
30th Aug 2017, 4:42 PM
Rabee Abbas
Rabee Abbas - avatar
30th Aug 2017, 5:09 PM
Rabee Abbas
Rabee Abbas - avatar
0
You can use array of strings instead of a switch, it is quicker to right/execute (not much but still) but bigger in memory (Here also not that much)
30th Aug 2017, 8:38 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
0
Anyway, your answer has been accepted, your algorythm is better and easier to write anyway :P
30th Aug 2017, 3:20 PM
Gabriel Popa
Gabriel Popa - avatar