# https://www.reddit.com/r/morsecode/comments/k9x18w/please_help_with_this_necklace/ # tried with # - https://github.com/dwyl/english-words/blob/master/words_alpha.txt (english) # - https://github.com/mertemin/turkish-word-list/edit/master/words.txt (turkish) # assuming single whole word, could try substrings as well import unidecode MORSE = {'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': '--..' } SEQ = "......-.-.....--." with open('words.txt', 'r') as words_f: # convert things to ascii words = {unidecode.unidecode(x).replace(' ', '') for x in words_f.read().splitlines()} def decode(curr, seq): # remove 'and curr in words' to see all possibilities if seq == "" and curr in words: print(curr) return for letter, code in MORSE.items(): if seq.startswith(code): decode(curr + letter, seq[len(code):]) decode("", SEQ)