Esempio n. 1
0
from bintree import Bintree

tree = Bintree()
print("Putta in ord, avsluta med retur")
while True:
    word = input()
    if word == "": break
    tree.put(word)
    print("Hela trädet:")
    tree.write()
    print("Sök ord, avsluta med retur")
    while True:
        word = input()
        if word == "":
            break
        if tree.exists(word):
            print(word, "finns")
Esempio n. 2
0
from queue import Queue
from bintree import Bintree

ordl = open('word3').read().split()

svenska = Bintree()
gamla = Bintree()

for o in ordl:
    svenska.put(o)

alfabet = "qweryuiopåasdfgjklöäzxcvbnm"

bfsqueue = Queue()


class bfsnode:
    value = None
    parent = None

    def __init__(self, value, parent):
        self.value = value
        self.parent = parent


def makesons(o, end):
    word = o.value
    for c in alfabet:
        for i in range(len(word)):
            if c == word[i]:
                continue
Esempio n. 3
0
from bintree import Bintree

f = open("word3")

ordlista = f.readlines()

for i in range(len(ordlista)):
    ordlista[i] = ordlista[i].rstrip()

swedish = Bintree()

for ord in ordlista:
    swedish.put(ord)

f.close()

f = open("english")

ordlista = f.read().split()

oldtree = Bintree()

for i in range(len(ordlista)):
    ordlista[i] = ordlista[i].strip('",.')

print(ordlista)

for o in ordlista:
    if oldtree.exists(o):
        continue
    if swedish.exists(o):
Esempio n. 4
0
def main():
    svenska = Bintree()
    engelska = Bintree()
    readFiles(svenska)
    readFilesE(engelska, svenska)
Esempio n. 5
0
fil = open("word3.txt")
ordlista = fil.read().split()
from bintree import Bintree

svenska = Bintree()  #träd med ordlistan
for ord in ordlista:
    svenska.put(ord)  #stoppar in orden från ordlistan i svenska binärträdet
gamla = Bintree()  #träd med alla besökta ord
startord = input("Ordet där du vill börja:")
slutord = input("Ordet du vill gå till:")


def makesons(o):
    alfabetet = "qwertyuiopåasdfghjklöäzxcvbnm"
    for tecken in alfabetet:
        for i in range(len(o)):
            child = o[:i] + tecken + o[i + 1:]
            if svenska.exists(child) and not gamla.exists(child):
                gamla.put(child)
                print(child)


makesons(startord)