Skip to content

Instantly share code, notes, and snippets.

@tallpeak
Created September 1, 2023 05:52
Show Gist options
  • Select an option

  • Save tallpeak/e82af53262aa213bfd8455ee793bcdf4 to your computer and use it in GitHub Desktop.

Select an option

Save tallpeak/e82af53262aa213bfd8455ee793bcdf4 to your computer and use it in GitHub Desktop.
morse code decoder, converted from perl by ChatGPT
morse = [' ', '-.-.--', '.-..-.', '', '...-..-', '', '.-...', '.----.', '-.--.', '-.--.-', '',
'.-.-.', '--..--', '-....-', '.-.-.-', '-..-.', '-----', '.----', '..---', '...--',
'....-', '.....', '-....', '--...', '---..', '----.', '---...', '-.-.-.', '', '-...-',
'', '..--..', '.--.-.', '.-', '-...', '-.-.', '-..', '.', '..-.', '--.', '....', '..',
'.---', '-.-', '.-..', '--', '-.', '---', '.--.', '--.-', '.-.', '...', '-', '..-',
'...-', '.--', '-..-', '-.--', '--..', '', '', '', '', '..--.-']
ascii_value = 32
morseAscii = {}
for m in morse:
ch = chr(ascii_value)
if m != '':
morseAscii[m] = ch
ascii_value += 1
message = "... --- ..."
decoded_message = ""
for w in message.split(" "):
if w in morseAscii:
decoded_message += morseAscii[w]
print(decoded_message)
@slamdon
Copy link

slamdon commented Feb 17, 2025

haven't seen the alphabet for the morse code, would you like to try morse code translator?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment