Last active
September 6, 2021 07:29
-
-
Save vesche/ada491d63d77d8afa55a599c787df957 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import requests | |
MORSE_MAP = { | |
'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': '--..' | |
} | |
url = 'https://raw.githubusercontent.com/dwyl/english-words/master/words_alpha.txt' | |
words = requests.get(url).text.splitlines() | |
for word in words: | |
morse_conv = ' '.join([MORSE_MAP[c] for c in word.upper()]) | |
if morse_conv == morse_conv[::-1] and len(word) > 4: | |
print(f'{word:12} {morse_conv}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment