#All Rights Reserved John Salguero #Starts the backend to my Youtube stream from problem_generator import generate_problem, normalize from mathhook import parse, solve from sympy import sympify #define the entry point to the programs def main(): problem = generate_problem() print("Generated Problem:") print(problem) print("Solve:") equation = apply_strategy(problem) expr = parse(equation) result = solve(expr, "x") print(result) def square_both_sides(problem): lhs, rhs = problem["problem"].split("=") lhs = sympify(lhs.strip()) rhs = sympify(rhs.strip()) lhs = lhs ** 2 rhs = rhs ** 2 return f"{normalize(lhs)} = {normalize(rhs)}" def factor_or_formula(problem) : return problem["problem"] def apply_strategy(problem): if problem["type"] == "radical": return square_both_sides(problem) if problem["type"] == "quadratics": return factor_or_formula(problem) return problem["problem"] #Starts the program if __name__ == "__main__": main()