Browse Source

Morsealphabet um Umlaute und Zahlen erweitert.

Bessere Namen für Variablen.
guess_chars in übergeordnete Funktion verpackt. So kann die untergeordnete rekursive Funktion auf ein lokales Array zurückgreifen, das die übergeordnete Funktion als Rückgabewert ausgibt.

Neue Funktion: ist schneller, basiert auf ganz anderem Prinzip
speedy-word-guess
M. Heiser 3 years ago
parent
commit
79df8245cd
1 changed files with 8 additions and 11 deletions
  1. +8
    -11
      main.py

+ 8
- 11
main.py View File

@ -44,7 +44,6 @@ alphabet = [["A", ".-"],
morse_cipher = "..-..--..-......-" morse_cipher = "..-..--..-......-"
def latin_to_morse(expression, delimiter=""): # expression: zu übersetzendes Wort def latin_to_morse(expression, delimiter=""): # expression: zu übersetzendes Wort
result = "" result = ""
for letter in expression: for letter in expression:
@ -115,22 +114,20 @@ def deciphering_1():
print("Found something: ", vocab_guesses) print("Found something: ", vocab_guesses)
dictDE_file = open("wordlist-german.txt", "r")
dictEN_file = open("wordlist-english.txt", "r")
dictDE_file = open("wordlist-german.txt", "r", encoding="utf-8")
dictEN_file = open("wordlist-english.txt", "r", encoding="utf-8")
#reader = csv.reader(dictDE_file)
#dictDE = [row[0].upper() for row in reader]
reader = csv.reader(dictDE_file)
dictDE = [row[0].upper() for row in reader]
reader = csv.reader(dictEN_file) reader = csv.reader(dictEN_file)
dictEN = [row[0].upper() for row in reader] dictEN = [row[0].upper() for row in reader]
dictionary = dictEN
dictionary = dictDE
#dictionary = ["FEMINIST", "TERESA", "INA", "ES", "MIT", "SEIT", "ID"] #dictionary = ["FEMINIST", "TERESA", "INA", "ES", "MIT", "SEIT", "ID"]
dictMORSE = wordlist_to_morse(dictionary) dictMORSE = wordlist_to_morse(dictionary)
print("dictMORSE erstellt") print("dictMORSE erstellt")
phrase_kit = guess_vocabs_BUT_AWESOME(morse_cipher, dictMORSE) phrase_kit = guess_vocabs_BUT_AWESOME(morse_cipher, dictMORSE)
for result in phrase_kit[17]:
print(result)
for result in phrase_kit[16]:
print(result)
for result in phrase_kit[15]:
for result in phrase_kit[1]:
print(result) print(result)

Loading…
Cancel
Save