small stress testing

This commit is contained in:
2026-05-01 19:26:08 -04:00
parent d8632115b1
commit 436dda33a3
7 changed files with 74 additions and 33 deletions

39
main.py
View File

@@ -3,19 +3,35 @@
from problem_generator import generate_problem
from steps_generator import generate_steps
from sympy import init_printing
from sympy import init_printing, sympify
#define the entry point to the programs
def main():
init_printing(order='lex')
problem = generate_problem()
steps = generate_steps(problem);
no_problem = True
test=sympify('-2')
while(no_problem):
problem = generate_problem()
steps = generate_steps(problem);
print("Generated Problem:")
print(problem)
print("Steps:")
pretty_print_steps(steps)
no_problem = check_solution(steps[-1]["after"], problem["solution"])
def check_solution(got, solution):
values = set([sympify(r.split("=")[1].strip()) for r in got.split(",")])
if is_iterable(solution) and not isinstance(solution, str):
solutions = set([sympify(r) for r in solution])
else:
solutions_list = []
solutions_list.append(sympify(solution))
solutions = set(solutions_list)
print(f"values:{values}, solutions:{solutions}")
return solutions == values
print("Generated Problem:")
print(problem)
print("Steps:")
pretty_print_steps(steps)
def pretty_print_steps(steps):
print("\n" + "=" * 50)
@@ -32,6 +48,13 @@ def pretty_print_steps(steps):
print("\n" + "=" * 50)
def is_iterable(obj):
try:
iter(obj)
return True
except TypeError:
return False
#Starts the program
if __name__ == "__main__":
main()