Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Nguyen-HanhNong committed Dec 24, 2024
2 parents 7ab0b30 + cc1da0b commit 7a806db
Show file tree
Hide file tree
Showing 14 changed files with 269 additions and 36 deletions.
10 changes: 5 additions & 5 deletions src/content/questions/comp2804/2014-fall-midterm/7/solution.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
${(5x-36)}^{100}$

$=\sum^{100}_{k=0} \binom{100}{k}{(5x)}^k {(-3y)}^{n-k}$
$ = \sum^{100}\_{k=0} \binom{100}{k} {(5x)}^{n-k} {(-3y)}^{k} $

$=\binom{100}{20}{(5x)}^{20} {(-3y)}^{80}$
We only consider $k=80$, as it results in $y^{80}$.

$=\binom{100}{20}5^{20} 3^{80} x^{20} y^{80}$
$ = \binom{100}{80} \cdot {(5x)}^{100-80} \cdot {(-3y)}^{80} $

$=\binom{100}{80}5^{20} 3^{80} x^{20} y^{80}$
$ = \binom{100}{80} \cdot 5^{20} \cdot {(-3)}^{80} \cdot x^{20} \cdot y^{80} $

$=\binom{100}{80}5^{20} 3^{80}$ (this is the coefficient)
$ = \binom{100}{80} \cdot 5^{20} \cdot 3^{80} $ (final answer, i.e. the coefficient of $x^{20} y^{80}$)
12 changes: 8 additions & 4 deletions src/content/questions/comp2804/2015-fall-final/4/solution.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
$ = \sum^{20}\_{k=0} \binom{20}{k} {(-3x)}^{k} {(5y)}^{20-k} $
$ = \sum^{20}\_{k=0} \binom{20}{k} {(-3x)}^{n-k} {(5y)}^{k} $

$ = \binom{20}{15} {(-3)}^{15} {5}^{5} x^{15} y^5 $
We only consider $k=5$, as it results in $y^{5}$.

$ = - \binom{20}{15} {(3)}^{15} {5}^{5} x^{15} y^5 $
$ = \binom{20}{5} \cdot {(-3x)}^{20-5} \cdot {(5y)}^{5} $

Thus, the coefficient of $x^{15}y^{5}$ in the expansion of ${(-3x + 5y)}^{20}$ is $ - \binom{20}{15} {(3)}^{15} {5}^{5} $
$ = \binom{20}{5} \cdot {(-3)}^{15} \cdot {5}^{5} \cdot x^{15} \cdot y^5 $

$ = - \binom{20}{5} \cdot {3}^{15} \cdot {5}^{5} \cdot x^{15} \cdot y^5 $

Thus, the coefficient of $x^{15}y^{5}$ in the expansion of ${(-3x + 5y)}^{20}$ is $ - \binom{20}{5} \cdot {3}^{15} \cdot {5}^{5} $
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ solution: comp2804/2015-fall-midterm/7/solution.md
tags:
- comp2804
- comp2804-midterm
- comp2804-newton's-binomial-theorem
- comp2804-the-pigeonhole-principle
---
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ solution: comp2804/2015-fall-midterm/8/solution.md
tags:
- comp2804
- comp2804-midterm
- comp2804-counting-solutions-of-linear-equations
- comp2804-newton's-binomial-theorem
---
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$=\sum^{88}_{k=0} \binom{88}{k}{(3x)}^k {(-17y)}^{88-k}$
$=\sum^{88}_{k=0} \binom{88}{k}{(3x)}^{88-k} {(-17y)}^{k}$

$=\binom{88}{7}{(3x)}^{81} {(-17y)}^{7}$

Expand Down
12 changes: 9 additions & 3 deletions src/content/questions/comp2804/2015-winter-final/4/solution.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
$ {(2x-7y)}^{15} $

$= \sum\_{k=4}^{15} \binom{15}{k} {(2x)}^{k} {(-7y)}^{15-k} $
$ = \sum\_{k=0}^{15} \binom{15}{k} {(2x)}^{n-k} {(-7y)}^{k} $

$ = \binom{15}{4} 2^{4} {(-7)}^{11} x^4 y^{11}$
We only consider $k=11$, as it results in $y^{11}$.

$ = - \binom{15}{4} 2^{4} {(7)}^{11} $
$ = \binom{15}{11} \cdot {(2x)}^{15-11} \cdot {(-7y)}^{11} $

$ = \binom{15}{11} \cdot 2^{4} \cdot {(-7)}^{11} \cdot x^4 \cdot y^{11} $

$ = - \binom{15}{4} \cdot 2^{4} \cdot 7^{11} \cdot x^4 \cdot y^{11} $

Thus, the coefficient of $ x^{4}y^{11} $ in the expansion of $ {(2x-7y)}^{15} $ is $ - \binom{15}{11} \cdot {2}^{4} \cdot {7}^{11} $
12 changes: 8 additions & 4 deletions src/content/questions/comp2804/2016-fall-midterm/9/solution.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
$ = \sum^{50}\_{k=0} \binom{50}{k} {(5x)}^{50-k} {(-7y)}^k $
$ = \sum^{50}\_{k=0} \binom{50}{k} {(5x)}^{n-k} {(-7y)}^k $

$ = \sum^{50}\_{k=0} \binom{50}{26} {(5x)}^{50-26} {(-7y)}^k $
We only consider $k=26$, as it results in $y^{26}$.

$ = \binom{50}{24} {(5)}^{24} x^{24} {(-7)}^{26} y^{26} $
$ = \binom{50}{26} \cdot {(5x)}^{50-26} \cdot {(-7y)}^{26} $

$ = \binom{50}{26} {(5)}^{24} {(-7)}^{26} x^{24} y^{26} $
$ = \binom{50}{26} \cdot {(5)}^{24} \cdot x^{24} \cdot {(-7)}^{26} \cdot y^{26} $

$ = \binom{50}{26} \cdot 5^{24} \cdot 7^{26} \cdot x^{24} \cdot y^{26} $

Thus, the coefficient is $ \binom{50}{26} \cdot 5^{24} \cdot 7^{26} $
12 changes: 6 additions & 6 deletions src/content/questions/comp2804/2017-fall-midterm/9/solution.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
$ = \sum^{100}\_{k=0} \binom{100}{k} {(7x)}^{k} {(-13y)}^{100-k} $
$ = \sum^{100}\_{k=0} \binom{100}{k} {(7x)}^{n-k} {(-13y)}^{k} $

$ = \sum^{100}\_{k=0} \binom{100}{20} {(7x)}^{20} {(-13y)}^{100-20} $
We only consider $k=80$, as it results in $y^{80}$.

$ = \binom{100}{20} {(7)}^{20} x^{20} {(-13)}^{80} y^{80} $
$ = \binom{100}{80} \cdot {(7x)}^{100-80} \cdot {(-13y)}^{80} $

$ = \binom{100}{20} {(7)}^{20} {(-13)}^{80} x^{20} y^{80} $
$ = \binom{100}{80} \cdot {(7)}^{20} \cdot x^{20} \cdot {(-13)}^{80} \cdot y^{80} $

$ = \binom{100}{20} {(7)}^{20} {(13)}^{80} x^{20} y^{80} $
$ = \binom{100}{80} \cdot 7^{20} \cdot 13^{80} \cdot x^{20} \cdot y^{80} $

Thus, the coefficient is $ \binom{100}{20} {(7)}^{20} {(13)}^{80} $
Thus, the coefficient is $ \binom{100}{80} \cdot 7^{20} \cdot 13^{80} $
12 changes: 8 additions & 4 deletions src/content/questions/comp2804/2018-fall-final/6/solution.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
$ = \sum\_{k = 35}^{55} \binom{55}{k} {(5x)}^{k} {(-3y)}^{n-k} $
$ = \sum\_{k=0}^{55} \binom{55}{k} {(5x)}^{n-k} {(-3y)}^{k} $

$ = \binom{55}{20} {(5x)}^{20} {(-3y)}^{35} $
We only consider $k=35$, as it results in $y^{35}$.

$ = - \binom{55}{20} 5^{20} 3^{35} x^{20} y^{35}$
$ = \binom{55}{35} \cdot {(5x)}^{55-35} \cdot {(-3y)}^{35} $

The coefficient is $ - \binom{55}{20} 5^{20} 3^{35} $
$ = \binom{55}{35} \cdot 5^{20} \cdot {(-3)}^{35} \cdot x^{20} \cdot y^{35}$

$ = - \binom{55}{35} \cdot 5^{20} \cdot 3^{35} \cdot x^{20} \cdot y^{35}$

The coefficient is $ - \binom{55}{35} \cdot 5^{20} \cdot 3^{35} $
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ul>
<li>$f(n) = 7 \cdot \frac{n!}{3^n}$ <br/>
$f(1) = 7 \cdot \frac{2!}{3^1} = 7 \cdot \frac{1}{3} = \frac{7}{3}$
$f(1) = 7 \cdot \frac{1!}{3^1} = 7 \cdot \frac{1}{3} = \frac{7}{3}$
<li>$f(n) = 7^n \cdot \frac{n!}{3^n}$ <br/>
$f(1) = 7^1 \cdot \frac{2!}{3^1} = 7 \cdot \frac{2}{3} = \frac{14}{3}$
<li>$f(n) = 7 \cdot \frac{(n + 1)!}{3^n}$ <br/>
Expand Down
106 changes: 106 additions & 0 deletions src/content/questions/comp2804/2022-winter-final/1/generator.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { describe, expect } from "@jest/globals";
import Generator from "./generator";

describe("comp2804/2022-winter-final/1", () => {
describe("generateValues", () => {
it("will return two values", () => {
const generator = new Generator();

const values = generator.generateValues();

expect(values).toHaveLength(2);
});

it("will return a string length between 50 and 100", () => {
const generator = new Generator();

const [stringLength, _] = generator.generateValues();

expect(stringLength).toBeGreaterThanOrEqual(50);
expect(stringLength).toBeLessThanOrEqual(100);
});

it("will return a positions value between 5 and 20", () => {
const generator = new Generator();

const [_, positions] = generator.generateValues();

expect(positions).toBeGreaterThanOrEqual(5);
expect(positions).toBeLessThanOrEqual(20);
});
});

describe("createOptions", () => {
it("will return five options", () => {
const generator = new Generator();

const options = generator.createOptions(50, 5);

expect(options).toHaveLength(5);
});

it("will have exactly one correct option", () => {
const generator = new Generator();

const options = generator.createOptions(50, 5);
const correctOptions = options.filter((option) => option.correct);

expect(correctOptions).toHaveLength(1);
});
});

describe("createCorrectOption", () => {
it("will return the correct option", () => {
const generator = new Generator();

const option = generator.createCorrectOption(50, 10);

expect(option.label).toBe("$\\binom{50}{10}\\cdot 4^{40}$");
expect(option.correct).toBe(true);
});
});

describe("createIncorrectOption1", () => {
it("will return an option with the combination being multiplied with 5 ^ value instead of 4 ^ value", () => {
const generator = new Generator();

const option = generator.createIncorrectOption1(50, 10);

expect(option.label).toBe("$\\binom{50}{10}\\cdot 5^{40}$");
expect(option.correct).toBe(false);
});
});

describe("createIncorrectOption2", () => {
it("will return an option with the combination using the number of letters instead of positions and being multiplied with 5 ^ value instead of 4 ^ value", () => {
const generator = new Generator();

const option = generator.createIncorrectOption2(50, 10);

expect(option.label).toBe("$\\binom{50}{5}\\cdot 5^{40}$");
expect(option.correct).toBe(false);
});
});

describe("createIncorrectOption3", () => {
it("will return an option with the combination using the number of letters instead of positions", () => {
const generator = new Generator();

const option = generator.createIncorrectOption3(50, 10);

expect(option.label).toBe("$\\binom{50}{5}\\cdot 4^{40}$");
expect(option.correct).toBe(false);
});
});

describe("createIncorrectOption4", () => {
it("will return an option which does not use combinations", () => {
const generator = new Generator();

const option = generator.createIncorrectOption4(50, 10);

expect(option.label).toBe("$5^{10}\\cdot 4^{40}$");
expect(option.correct).toBe(false);
});
});
});
106 changes: 106 additions & 0 deletions src/content/questions/comp2804/2022-winter-final/1/generator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { MultipleChoiceQuestionGenerator } from "@common/MultipleChoiceQuestionGenerator";
import type {
MultipleChoiceQuestion,
MultipleChoiceQuestionOption,
} from "@common/MultipleChoiceQuestionGenerator";

class Generator extends MultipleChoiceQuestionGenerator {
generateQuestion(): MultipleChoiceQuestion {
const [stringLength, positions] = this.generateValues();
const dynamicQuestionBody = `Consider strings of length $${stringLength}$, in which each character is one of the characters $a,b,c,d,e$. How many such strings have exactly $${positions}$ letters $e$?`;
return {
body: dynamicQuestionBody,
options: this.createOptions(stringLength, positions),
};
}

generateValues(): [number, number] {
const stringLength = Math.floor(Math.random() * 51) + 50; //generate a value between 50 and 100
const positions = Math.floor(Math.random() * 16) + 5; //generate a value between 5 and 20

return [stringLength, positions];
}

createOptions(
stringLength: number,
positions: number,
): MultipleChoiceQuestionOption[] {
const correctOption = this.createCorrectOption(stringLength, positions);
const incorrectOption1 = this.createIncorrectOption1(
stringLength,
positions,
);
const incorrectOption2 = this.createIncorrectOption2(
stringLength,
positions,
);
const incorrectOption3 = this.createIncorrectOption3(
stringLength,
positions,
);
const incorrectOption4 = this.createIncorrectOption4(
stringLength,
positions,
);

return this.shuffleOptions([
correctOption,
incorrectOption1,
incorrectOption2,
incorrectOption3,
incorrectOption4,
]);
}

createCorrectOption(
stringLength: number,
positions: number,
): MultipleChoiceQuestionOption {
return {
label: `$\\binom{${stringLength}}{${positions}}\\cdot 4^{${stringLength - positions}}$`,
correct: true,
};
}

createIncorrectOption1(
stringLength: number,
positions: number,
): MultipleChoiceQuestionOption {
return {
label: `$\\binom{${stringLength}}{${positions}}\\cdot 5^{${stringLength - positions}}$`,
correct: false,
};
} //mutliples with 5 ^ value instead of 4

createIncorrectOption2(
stringLength: number,
positions: number,
): MultipleChoiceQuestionOption {
return {
label: `$\\binom{${stringLength}}{5}\\cdot 5^{${stringLength - positions}}$`,
correct: false,
};
} //uses number of letters instead of positions and multiples with 5 ^ value instead of 4

createIncorrectOption3(
stringLength: number,
positions: number,
): MultipleChoiceQuestionOption {
return {
label: `$\\binom{${stringLength}}{5}\\cdot 4^{${stringLength - positions}}$`,
correct: false,
};
} //uses number of letters instead of positions

createIncorrectOption4(
stringLength: number,
positions: number,
): MultipleChoiceQuestionOption {
return {
label: `$5^{${positions}}\\cdot 4^{${stringLength - positions}}$`,
correct: false,
};
} //does not use combinations
}

export default Generator;
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type: multiple-choice
author: Michiel Smid
question: comp2804/2022-winter-final/1/question.ts
solution: comp2804/2022-winter-final/1/solution.md
generator: comp2804/2022-winter-final/1/generator.ts
tags:
- comp2804
- comp2804-final
Expand Down
14 changes: 8 additions & 6 deletions src/content/questions/comp2804/2022-winter-final/6/solution.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
$ (2x - 3y)^{30} $

$ = \sum\_{k=10}^{30} \binom{30}{k} \cdot (2x)^{k} \cdot (-3y)^{30-k} $
$ = \sum\_{k=0}^{30} \binom{30}{k} \cdot (2x)^{n-k} \cdot (-3y)^{k} $

$ = \binom{30}{10} \cdot (2x)^{10} \cdot (-3y)^{30-10} $
We only consider $k=20$, as it results in $y^{20}$.

$ = \binom{30}{10} \cdot (2x)^{10} \cdot (-3y)^{20} $
$ = \binom{30}{20} \cdot (2x)^{30-20} \cdot (-3y)^{20} $

$ = \binom{30}{10} \cdot 2^{10} \cdot (-3)^{20} \cdot x^{10} \cdot y^{20} $
$ = \binom{30}{20} \cdot (2x)^{10} \cdot (-3y)^{20} $

$ = \binom{30}{10} \cdot 2^{10} \cdot (3)^{20} \cdot x^{10} \cdot y^{20} $
$ = \binom{30}{20} \cdot 2^{10} \cdot (-3)^{20} \cdot x^{10} \cdot y^{20} $

From this equation, we can see that the coefficient (aka the real numbers) are: $\binom{30}{10} \cdot 2^{10} \cdot (3)^{20}$
$ = \binom{30}{20} \cdot 2^{10} \cdot (3)^{20} \cdot x^{10} \cdot y^{20} $

From this equation, we can see that the coefficient (aka the real numbers) are: $\binom{30}{20} \cdot 2^{10} \cdot 3^{20}$

0 comments on commit 7a806db

Please sign in to comment.