From 4e9e0e1d1b751a41e40bcc5804c00d724a77027b Mon Sep 17 00:00:00 2001 From: NoahTheCorgi <91349811+NoahTheCorgi@users.noreply.github.com> Date: Mon, 14 Mar 2022 10:18:32 -0400 Subject: [PATCH] adjusted the problem scenario to be unique compared to other pre-existing generators --- .../comp2804/coefficient_of_term/main.py | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/dynamic/generators/comp2804/coefficient_of_term/main.py b/dynamic/generators/comp2804/coefficient_of_term/main.py index 0d32f157..6880e55d 100644 --- a/dynamic/generators/comp2804/coefficient_of_term/main.py +++ b/dynamic/generators/comp2804/coefficient_of_term/main.py @@ -1,21 +1,25 @@ -""" What is the coefficient of x^a * y^b for the expansion of (cx+dy)^n ? """ +""" What is the coefficient of x^a * y^b for the expansion of (cx^s+dy^t)^n ? """ """ This generator creates a randomized problem of figure out the coefficient -of a specific form x^{a}y^{b} for a given (cx+dy)^n """ +of a specific form x^{a}y^{b} for a given (cx^s+dy^t)^n """ import random def generate_question(): - a = random.randint(5, 15) - b = random.randint(5, 15) + s = random.randint(1, 5) + t = random.randint(1, 5) + + multiply_s = random.randint(5, 15) + multiply_t = random.randint(5, 15) + + a = s * multiply_s + b = t * multiply_t + c = random.randint(2, 7) d = random.randint(2, 7) - n = a + b - - variation_variable_1 = random.randint(1, 3) - variation_variable_2 = random.randint(1, 3) + n = multiply_s + multiply_t question_body = ( "What is the coefficient of the term $x^{" @@ -25,9 +29,14 @@ def generate_question(): + "}$, in the expansion of " + "$(" + str(c) - + "x + " + + " \\cdot x^{" + + str(s) + + "} + " + str(d) - + "y)^{" + + " \\cdot y^{" + + str(t) + + "})" + + "^{" + str(n) + "}$" ) @@ -36,22 +45,22 @@ def generate_question(): "$\\binom{" + str(n) + "}{" - + str(a) + + str(multiply_s) + "} \\cdot " + str(c) + "^{" - + str(a) + + str(multiply_s) + "} \\cdot " + str(d) + "^{" - + str(b) + + str(multiply_t) + "}$" ) varied_answer_1 = ( "$\\binom{" + str(n) + "}{" - + str(a + variation_variable_1) + + str(multiply_s) + "} \\cdot " + str(c) + "^{" @@ -66,30 +75,30 @@ def generate_question(): "$\\binom{" + str(n) + "}{" - + str(a - variation_variable_2) + + str(s) + "} \\cdot " + str(c) + "^{" - + str(a + 1) + + str(s) + "} \\cdot " + str(d) + "^{" - + str(b + variation_variable_1) + + str(t) + "}$" ) varied_answer_3 = ( "$\\binom{" + str(n) + "}{" - + str(a) + + str(s) + "} \\cdot " + str(c) + "^{" - + str(a) + + str(multiply_s) + "} \\cdot " + str(d) + "^{" - + str(b - variation_variable_2) + + str(multiply_t) + "}$" )