Einzelfunktionenexperimentierverzeichnis in git integriert

This commit is contained in:
2024-03-17 11:13:48 +01:00
parent 99bd1032c2
commit be9e204576
20 changed files with 1025 additions and 1 deletions

View File

@@ -0,0 +1,37 @@
#!/usr/bin/python
# -*- coding: utf8 -*-
def buchstabenzaehl(buchstabe, anzahl):
if buchstabe in anzahl:
anzahl[buchstabe] = anzahl[buchstabe] + 1
else:
anzahl[buchstabe] = 1
def wortzaehl(wort):
anzahl = {}
for buchstabe in wort:
buchstabenzaehl(buchstabe.upper(), anzahl)
return anzahl
while 1:
print("Zum Beenden: kein Wort eingeben und Return drücken")
eingabe = input("Bitte Wort eingeben für welches Anagramme gesucht werden sollen: ")
eingabe = eingabe.rstrip()
if eingabe == "":
break
eingabezaehl = wortzaehl(eingabe)
wbfile = open("../../data/german.dic", "r") # german.dic von https://sourceforge.net/projects/germandict/
for line in wbfile:
line = line.strip(" \t\n\r")
if eingabe.upper() == line.upper():
continue
if len(eingabe) != len(line):
continue
if eingabezaehl == wortzaehl(line):
print(line)
wbfile.close()
print("---keine weiteren Anagramme gefunden---")
print()
print("Ich hoffe es hat geholfen! Bye,Bye!")