def __init__(self): NineTailModel.__init__(self) # Invoke superclass constructor # Create a graph vertices = [x for x in range(NUMBER_OF_NODES)] graph = WeightedGraph(vertices, getWeightedEdges()); # Obtain a BSF tree rooted at the target node self.tree = graph.getShortestPath(511)
def main(): # Prompt the user to enter nine coins H's and T's initialNode = input("Enter an initial nine coin H's and T's: ").strip() # Create the NineTaileModel model = NineTailModel() path = model.getShortestPath(getIndex(initialNode)) print("The steps to flip the coins are ") for i in range(len(path)): printNode(getNode(path[i]))
def main(): # Prompt the user to enter nine coins H's and T's initialNode = \ input("Enter an initial nine coin H's and T's: ").strip() # Create the NineTaileModel model = NineTailModel() path = model.getShortestPath(getIndex(initialNode)) print("The steps to flip the coins are "); for i in range(len(path)): printNode(getNode(path[i]))
def solve(): c = "".join(coins.get()) model = NineTailModel() path = model.getShortestPath(getIndex(c)) canvas.delete(ALL) x = 10 y = 10 canvas.config(width = 50 + (50* len(path))) for i in range(len(path)): node = getNode(path[i]) for j in range(3): for k in range(3): canvas.create_rectangle(x, y, x+10, y + 20) canvas.create_text(x + 5, y + 10, text = node[j+k]) x += 10 x = x - 30 y += 20 x += 50 y = 10
from WeightedNineTailModel import WeightedNineTailModel from NineTailModel import NineTailModel node = 511 tree1 = WeightedNineTailModel() depth1 = tree1.getShortestPath(node) tree2 = NineTailModel() depth2 = tree2.getShortestPath(node) if depth1 != depth2: print("They are not the same") else: print("They are the same")