a third through Step Generator

This commit is contained in:
2026-04-29 06:27:05 -04:00
parent 63f32a51cb
commit 680c59513c
9 changed files with 492 additions and 66 deletions

35
main.py
View File

@@ -1,44 +1,19 @@
#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
from problem_generator import generate_problem
from steps_generator import generate_steps
#define the entry point to the programs
def main():
problem = generate_problem()
steps = generate_steps(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"]
print("Steps:")
print(steps)
#Starts the program
if __name__ == "__main__":