#print("changes"+str(changes)) if len(changes) == 0: #jumble = math.associative_jumble(str(tree)) #print("jumble: " + str(jumble)) return tree #print(changes[0]) #print("change being made: " + str(changes[0][1])) replacement = do_math(changes[0]) #print("replacement: " + str(replacement)) simplified = simplified.replace(changes[0][1][0], replacement) #print("current: "+str(simplified)) new_tree = eqsim.reparse(simplified) return simplify_expression(new_tree) tree = eqsim.parse() possible_matches = expr.look_for_match(str(tree)) possible_changes = expr.find_changes(str(tree)) #print("possible matches: " + str(possible_matches)) #BFSarray = BFS(tree) #DFSarray = DFS(tree) #print("BFS: " + str(BFSarray)) #print("DFS: " + str(DFSarray)) #changeA = valid_changes(DFSarray) #changeB = valid_changes(BFSarray) #print("A: " + str(changeA))
import equationsimplier as eqs import eqparser as parse import ariithmetic as arith equation = eqs.parse() print(equation[0]) print(equation[1]) print(str(equation)) print(equation) num_paren = 0 substring = "" postfix = str(equation[0]).strip() infix = str(equation[1]).strip() #sub_problems = [] print (postfix) print (infix) def seperate_left_right(expression): print("expression[0]:" + str(expression[0])) print("expression[1]:" + str(expression[1])) print("expression[2]:" + str(expression[2])) if not(expression[0] == '(' and expression[1] == '='): print("seperate_left_right function requires postfix notation") return ("","") else: num_paren = 0 posisition = 0 for i in range(3,len(expression)):
import equationsimplier as eqs import eqparser as parse import ariithmetic as arith equation = eqs.parse() print(equation[0]) print(equation[1]) print(str(equation)) print(equation) num_paren = 0 substring = "" postfix = str(equation[0]).strip() infix = str(equation[1]).strip() #sub_problems = [] print(postfix) print(infix) def seperate_left_right(expression): print("expression[0]:" + str(expression[0])) print("expression[1]:" + str(expression[1])) print("expression[2]:" + str(expression[2])) if not (expression[0] == '(' and expression[1] == '='): print("seperate_left_right function requires postfix notation") return ("", "") else: num_paren = 0 posisition = 0
#changes = expr.find_changes(simplified) #print("changes"+str(changes)) if len(changes) == 0: #jumble = math.associative_jumble(str(tree)) #print("jumble: " + str(jumble)) return tree #print(changes[0]) #print("change being made: " + str(changes[0][1])) replacement = do_math(changes[0]) #print("replacement: " + str(replacement)) simplified = simplified.replace(changes[0][1][0],replacement) #print("current: "+str(simplified)) new_tree = eqsim.reparse(simplified) return simplify_expression(new_tree) tree = eqsim.parse() possible_matches = expr.look_for_match(str(tree)) possible_changes = expr.find_changes(str(tree)) #print("possible matches: " + str(possible_matches)) #BFSarray = BFS(tree) #DFSarray = DFS(tree) #print("BFS: " + str(BFSarray)) #print("DFS: " + str(DFSarray)) #changeA = valid_changes(DFSarray) #changeB = valid_changes(BFSarray)