# Morse code day - April 27th

**URL:** <https://discourse.julialang.org/t/morse-code-day-april-27th/80261>\
**Category:** General Usage\
**Created:** [April 29, 2022, 3:40pm UTC](https://discourse.julialang.org/t/morse-code-day-april-27th/80261 "2022-04-29T15:40:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![scelles](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scelles/32/220408_2.png) [@scelles](https://discourse.julialang.org/u/scelles)\
**Post date:** [April 29, 2022, 3:40pm UTC](https://discourse.julialang.org/t/morse-code-day-april-27th/80261/1 "2022-04-29T15:40:26Z")

</div>

Hello,

Morse code day was April 27th [https://www.daysoftheyear.com/days/morse-code-day/](https://www.daysoftheyear.com/days/morse-code-day/)

I noticed no package for morse code seems to exist with Julia

> **[Julia Packages](https://juliapackages.com/packages?search=morse)**
>
> One stop shop for the Julia package ecosystem.

Here is my small (and late) contribution

```julia
module MorseCode

using OrderedCollections: OrderedDict

const ALPHANUMERIC_TO_MORSE = OrderedDict(
    'A' => ".-", 'B' => "-...", 'C' => "-.-.", 'D' => "-..", 'E' => ".",
    'F' => "..-.", 'G' => "--.", 'H' => "....", 'I' => "..", 'J' => ".---",
    'K' => "-.-", 'L' => ".-..", 'M' => "--", 'N' => "-.", 'O' => "---",
    'P' => ".--.", 'Q' => "--.-", 'R' => ".-.", 'S' => "...", 'T' => "-",
    'U' => "..-", 'V' => "...-", 'W' => ".--", 'X' => "-..-", 'Y' => "-.--", 'Z' => "--..",

    '1' => ".----", '2' => "..---", '3' => "...--", '4' => "....-", '5' => ".....",
    '6' => "-....", '7' => "--...", '8' => "---..", '9' => "----.", '0' => "-----",

    '&' => ".-...", '\'' => ".----.", '@' => ".--.-.", ')' => "-.--.-", '(' => "-.--.",
    '⇒' => "---...", ',' => "--..--", '=' => "-...-", '!' => "-.-.--", '.' => ".-.-.-",
    '-' => "-....-", '+' => ".-.-.", '?' => "..--..", '/' => "-..-."
)

const MORSE_TO_ALPHANUMERIC = Dict(value => key for (key, value) in ALPHANUMERIC_TO_MORSE)

function encode(sentence)
    sentence = uppercase(sentence)
    morse_code = String[]
    for c in sentence
        if c == ' '
            push!(morse_code, " ")
        else
            push!(morse_code, ALPHANUMERIC_TO_MORSE[c])
        end
    end
    return join(morse_code, " ")
end

function decode(morse_code)
    morse_code = split(morse_code, " ")
    sentence = String[]
    for morse_symbol in morse_code
        if morse_symbol == ""
            push!(sentence, " ")
        else
            push!(sentence, string(MORSE_TO_ALPHANUMERIC[morse_symbol]))
        end
    end
    return replace(join(sentence), " " => " ")
end

end # module

```

```julia
julia> decode(".... . .-.. .-.. --- .--- ..- .-.. .. .- -.-.--")

```

Maybe we can expect to have the current situation improved for next year 😉

I’m pretty sure nice projects could be done in this field using Julia

> **[Morse Learning Machine - v1](https://www.kaggle.com/c/morse-challenge)**
>
> Build a learning machine to decode audio files containing Morse code.

> **[Morse Learning Machine Challenge - v2](https://www.kaggle.com/c/morse-learning-machine-challenge-v2)**
>
> Build a learning machine to decode audio files containing Morse code.

> **[Happy Morse Code Day](https://www.kaggle.com/code/bryanb/happy-morse-code-day/notebook)**
>
> Explore and run machine learning code with Kaggle Notebooks | Using data from No attached data sources

Kind regards

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [May 2, 2022, 4:09am UTC](https://discourse.julialang.org/t/morse-code-day-april-27th/80261/2 "2022-05-02T04:09:27Z")

</div>

```julia
--. --- --- -.. / ... ..- --. --. . ... - .. --- -. -.-.--

```

---

<div class="post-metadata">

**Author:** ![scelles](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scelles/32/220408_2.png) [@scelles](https://discourse.julialang.org/u/scelles)\
**Post date:** [May 2, 2022, 7:13am UTC](https://discourse.julialang.org/t/morse-code-day-april-27th/80261/3 "2022-05-02T07:13:15Z")

</div>

Some ideas…

```julia
-... ..- .. .-.. -.. .- .--- ..- .-.. .. .- .--. .- -.-. -.- .- --. . ..-. --- .-. . -. -.-. --- -.. .. -. --. -.. . -.-. --- -.. .. -. --.   
- . -..- - - --- -- --- .-. ... . .- -. -.. -- --- .-. ... . - --- - . -..- - --..-- -.-. .-. . .- - . -- --- .-. ... . -... .. -. .- .-. -.-- - .-. . . -.--. -.. .. -.-. .... --- - --- -- .. -.-. ... . .- .-. -.-. .... - .- -... .-.. . -.--.- --..-- -.-. .-. . .- - . .- .--- ..- .-.. .. .- ... -.-. .-. .. .--. - ... .. -- .. .-.. .- .-. - --- -- --- .-. ... . .-.-.- .--. -.-- ..-. .-. --- -- -.- .- --. --. .-.. . -- --- .-. ... . -.-. .... .- .-.. .-.. . -. --. . - --- .-.. .. ... - . -. .- -. -.. -.. .. ... .--. .-.. .- -.-- .-- .- ...- -- --- .-. ... . -.-. --- -.. . ..-. .. .-.. . --..-- -.-. .-. . .- - . .--- ..- .-.. .. .- -.-. --- -.. . - --- -.. . -.-. --- -.. . .-- .- ...- -- --- .-. ... . ..-. .. .-.. . .- -. -.. -... ..- .. .-.. -.. .- .--- ..- .-.. .. .- .-. . .- .-.. - .. -- . -.. . -.-. --- -.. . .-. .- .-. . ... --- -- . ... ..- --. --. . ... - .. --- -. ... .-.-.- -.- . . .--. -- . .. -. ..-. --- .-. -- . -.. -.-.--

```

---

<div class="post-metadata">

**Author:** ![scelles](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scelles/32/220408_2.png) [@scelles](https://discourse.julialang.org/u/scelles)\
**Post date:** [December 8, 2024, 5:05pm UTC](https://discourse.julialang.org/t/morse-code-day-april-27th/80261/4 "2024-12-08T17:05:04Z")

</div>

```julia
.-- . / .... .- ...- . / -. --- .-- / -.-. .-.. .- ... ... .. -.-. -.-. .. .--. .... . .-. ... .--- .-..

```

See [GitHub - s-celles/ClassicCiphers.jl: ClassicCiphers.jl is a Julia package that implements various classical cryptographic ciphers.](https://github.com/s-celles/ClassicCiphers.jl) and [ClassicCiphers.jl - A Julia Package for Classical Cryptography - #4 by scelles](https://discourse.julialang.org/t/classicciphers-jl-a-julia-package-for-classical-cryptography/123564/4)

---

<div class="post-metadata">

**Author:** ![scelles](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scelles/32/220408_2.png) [@scelles](https://discourse.julialang.org/u/scelles)\
**Post date:** [April 7, 2025, 7:54am UTC](https://discourse.julialang.org/t/morse-code-day-april-27th/80261/5 "2025-04-07T07:54:23Z")

</div>

You may also like

- Baby Morse [Baby Morse](https://hackropole.fr/en/challenges/hardware/fcsc2022-hardware-baby-morse/)
- Daddy Morse [Daddy Morse - Hackropole](https://hackropole.fr/en/challenges/hardware/fcsc2022-hardware-daddy-morse/)
- Mommy Morse [Mommy Morse](https://hackropole.fr/en/challenges/hardware/fcsc2022-hardware-mommy-morse)

It’s Python oriented but can be solved with any language (and so Julia)
