예제 #1
0
파일: a1.py 프로젝트: MaxKrog/KTH
                if not dumbTree.exists(testWord):
                    dumbTree.put(testWord)
                    queue.put(ParentNode(testWord, node))


sweTree = BST()
dumbTree = BST()

queue = LinkedQueue()

sweAlpha = list("abcdefghijklmnopqrstuvwxyzåäö")

with open("texts/word3.txt", "r") as wordLines:
    for word in wordLines:
        word = word.rstrip("\n")
        if not sweTree.exists(word):
            sweTree.put(word)

print(
    "Detta program kommer att hitta vilka ord som ligger längst ifrån ditt startord."
)
startWord = input("Startord:")

startNode = ParentNode(startWord)

dumbTree.put(startNode.value)
queue.put(startNode)

maxDistance = 0
words = []
예제 #2
0
파일: 1.py 프로젝트: MaxKrog/KTH
from module import BST

sweTree = BST()
dumbTree = BST()

sweAlpha = list("abcdefghijklmnopqrstuvwxyzåäö")

with open("texts/word3.txt",
          "r") as wordLines:  #Loads words into a Binary Search Tree.
    for word in wordLines:
        word = word.rstrip("\n")
        if not sweTree.exists(word):
            sweTree.put(word)

print("Detta program visar alla 'barn' till ett ord")
startWord = input("Faderord:")
dumbTree.put(startWord)

for n in range(3):  #Change all the letters to all the possible. One at a time.
    for char in sweAlpha:
        testWord = list(startWord)  # "str.." -> ["s","t","r",...]
        testWord[n] = char
        testWord = "".join(testWord)  # ["s","t","r",...] -> "str.."
        if sweTree.exists(testWord):
            if not dumbTree.exists(testWord):
                print(testWord)
                dumbTree.put(testWord)
예제 #3
0
파일: 3.py 프로젝트: MaxKrog/KTH
			elif sweTree.exists(testWord):
				if not dumbTree.exists(testWord):
					dumbTree.put(testWord)
					queue.put(ParentNode(testWord,node))

sweTree = BST()
dumbTree = BST()

queue = LinkedQueue()

sweAlpha = list("abcdefghijklmnopqrstuvwxyzåäö")

with open("texts/word3.txt","r") as wordLines:
	for word in wordLines:
		word = word.rstrip("\n")
		if not sweTree.exists(word):
			sweTree.put(word)

print("Detta program kommer hitta den snabbaste vägen mellan två trekaraktärs-ord.")
startWord = input("Startord:")
endWord = input("Slutord:")

startNode = ParentNode(startWord)

dumbTree.put(startNode.value)
queue.put(startNode)

while not queue.isEmpty():
	node = queue.get()
	makeChildren(node)
예제 #4
0
파일: 1.py 프로젝트: MaxKrog/KTH
from module import BST

sweTree = BST()
dumbTree = BST()

sweAlpha = list("abcdefghijklmnopqrstuvwxyzåäö")


with open("texts/word3.txt","r") as wordLines: #Loads words into a Binary Search Tree.
	for word in wordLines:
		word = word.rstrip("\n")
		if not sweTree.exists(word):
			sweTree.put(word)

print("Detta program visar alla 'barn' till ett ord")
startWord = input("Faderord:")
dumbTree.put(startWord)

for n in range(3): 						#Change all the letters to all the possible. One at a time.
	for char in sweAlpha:
		testWord = list(startWord) 		# "str.." -> ["s","t","r",...]
		testWord[n] = char
		testWord = "".join(testWord) 	# ["s","t","r",...] -> "str.."
		if sweTree.exists(testWord):	
			if not dumbTree.exists(testWord):
				print(testWord)
				dumbTree.put(testWord)