Posted on Leave a comment

An active mind is a healthy mind

Knocking the plaques off the brain. Began the day with some Spanish practice and some Morse code practice. Then jumped into codewars.com and the first challenge I was given was…”write a Morse code decoder!”
Here’s my passing code (wordpress stripped the indentions):
function decode_morse(string $code): string {
$returnstring = ”;

//break the input string into words based on three spaces between words
$morsewords = explode(‘ ‘,$code);
foreach($morsewords as &$word){

//translate each letter of each word from Morse using the built-in library
$morse = explode(‘ ‘,$word);
foreach($morse as &$value){
$returnstring .= MORSE_CODE[$value];
}
$returnstring .= ‘ ‘;
}

//clean up return string by removing any leading or trailing spaces we added or that were in the original input string
return trim($returnstring);

}
Now to return to becoming a PowerApps and Azure expert. Light the incense, dim the lights, and turn up the cyberpunk. I’m going in!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.