Step Generator Polish, untested
This commit is contained in:
@@ -207,7 +207,8 @@ def generate_like_terms_steps (problem):
|
||||
return steps
|
||||
|
||||
@register_steps_generator("quadratic")
|
||||
def generate_quadratic_steps (problem):
|
||||
def generate_quadratic_steps (problem, skip_check=False):
|
||||
print(f"calling generate_quadratic_steps with: {problem["problem"]}")
|
||||
#ax² + bx + c = 0
|
||||
steps = []
|
||||
|
||||
@@ -245,12 +246,13 @@ def generate_quadratic_steps (problem):
|
||||
current = steps[-1]["after"]
|
||||
|
||||
# Check for incorrect answers
|
||||
steps.extend(algebraic_steps.check_roots(problem["problem"], current))
|
||||
if not skip_check:
|
||||
steps.extend(algebraic_steps.check_roots(problem["problem"], current))
|
||||
|
||||
return steps
|
||||
|
||||
@register_steps_generator("difference_squares")
|
||||
def generate_difference_squares_steps (problem):
|
||||
def generate_difference_squares_steps (problem, skip_check=False):
|
||||
#x² - a² = 0
|
||||
steps = []
|
||||
|
||||
@@ -277,7 +279,8 @@ def generate_difference_squares_steps (problem):
|
||||
current = steps[-1]["after"]
|
||||
|
||||
# Check for incorrect answers
|
||||
steps.extend(algebraic_steps.check_roots(problem["problem"], current))
|
||||
if not skip_check:
|
||||
steps.extend(algebraic_steps.check_roots(problem["problem"], current))
|
||||
|
||||
return steps
|
||||
|
||||
@@ -292,7 +295,7 @@ def generate_zero_product_steps (problem):
|
||||
return steps
|
||||
|
||||
@register_steps_generator("radical")
|
||||
def generate_radical_steps (problem):
|
||||
def generate_radical_steps (problem, skip_check=False):
|
||||
#√(x + a) = b
|
||||
steps = []
|
||||
x = symbols('x')
|
||||
@@ -321,7 +324,8 @@ def generate_radical_steps (problem):
|
||||
current = steps[-1]["after"]
|
||||
|
||||
# Check for incorrect answers
|
||||
steps.extend(algebraic_steps.check_roots(problem["problem"], current))
|
||||
if not skip_check:
|
||||
steps.extend(algebraic_steps.check_roots(problem["problem"], current))
|
||||
|
||||
return steps
|
||||
|
||||
@@ -375,7 +379,7 @@ def generate_binomial_steps (problem):
|
||||
init_printing(order='lex')
|
||||
|
||||
## Combine Like Terms
|
||||
steps.append(algebraic_steps.combine_like_terms(current))
|
||||
steps.extend(algebraic_steps.combine_like_terms(current))
|
||||
current = steps[-1]["after"]
|
||||
left, right = current.split("=")
|
||||
left_expr = parse_expr(left, transformations=transformations)
|
||||
@@ -404,7 +408,7 @@ def generate_binomial_steps (problem):
|
||||
return steps
|
||||
|
||||
@register_steps_generator("tricky")
|
||||
def generate_tricky_steps (problem):
|
||||
def generate_tricky_steps (problem, skip_check=False):
|
||||
#(x² - x - a) / (x + b) = c
|
||||
steps = []
|
||||
x = symbols('x')
|
||||
@@ -429,16 +433,16 @@ def generate_tricky_steps (problem):
|
||||
current = steps[-1]["after"]
|
||||
|
||||
# Combine Like Terms
|
||||
steps.append(algebraic_steps.combine_like_terms(current))
|
||||
steps.extend(algebraic_steps.combine_like_terms(current))
|
||||
current = steps[-1]["after"]
|
||||
|
||||
# Solve Quadratic
|
||||
print(f"calling generate_quadratic_steps with: {current}")
|
||||
steps.extend(generate_quadratic_steps({"problem" : current}))
|
||||
steps.extend(generate_quadratic_steps({"problem" : current}, True))
|
||||
current = steps[-1]["after"]
|
||||
|
||||
# Check for incorrect answers
|
||||
steps.extend(algebraic_steps.check_roots(problem["problem"], current))
|
||||
if not skip_check:
|
||||
steps.extend(algebraic_steps.check_roots(problem["problem"], current))
|
||||
|
||||
return steps
|
||||
|
||||
|
||||
Reference in New Issue
Block a user