# mwittels/khan-exercises forked from Khan/khan-exercises

### Subversion checkout URL

You can clone with
or
.

# Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

# Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
• 4 commits
• 4 files changed
• 3 contributors
Commits on Aug 09, 2012
 spicyj Fix anonymous function problem here too c08f771 beneater Add user crc32 hash to issue reports to facilitate deduplication Reviewers: josh Reviewed By: josh CC: alpert Differential Revision: http://phabricator.khanacademy.org/D565 2894325
Commits on Aug 10, 2012
 beneater Add exercise: Solutions to quadratic equations Reviewers: mark Reviewed By: mark Differential Revision: http://phabricator.khanacademy.org/D569 4a5168a mwittels add probability with permutations and combinations exercise Reviewers: eater, emily Reviewed By: eater Differential Revision: http://phabricator.khanacademy.org/D460 a18d57f
200 exercises/probability_with_perm_comb.html
 @@ -0,0 +1,200 @@ + + + + + Probability with permutations and combinations + + + +
+
+
+
+ randRange(7,10) + randRange(3,6) + randRange(2,STUDENTS-2) + STUDENTS-BOYS + random() < 0.5 + ARE_B ? BOYS : GIRLS + (factorial(NUM_B)*factorial(STUDENTS-GROUP))/(factorial(STUDENTS)*factorial(NUM_B-GROUP)) + getGCD(factorial(NUM_B)*factorial(STUDENTS-GROUP),factorial(STUDENTS)*factorial(NUM_B-GROUP)) + factorial(NUM_B)*factorial(STUDENTS-GROUP)/GCD + factorial(STUDENTS)*factorial(NUM_B-GROUP)/GCD +
+

+ There are STUDENTS students in a class: BOYS boys and + GIRLS girls. +

+

+ If the teacher picks a group of GROUP at random, what is the probability that + everyone in the group is a ARE_B ? "boy" : "girl"? +

+
+
+

+ One way to solve this problem is to figure out how many different groups + there are of only ARE_B ? "boys" : "girls", then divide this + by the total number of groups you could choose. Since every groups is chosen + with equal probability, this will be the probability that a group of all + ARE_B ? "boys" : "girls" is chosen. +

+

+ We know two ways to count the number of groups we can choose: we use permutations if order matters, + and combinations if it doesn't. Does the order the students are picked matter in this case? +

+
+

+ It doesn't matter if we pick ARE_B ? "John" : "Julia" then + ARE_B ? "Ben" : "Beatrice" or ARE_B ? "Ben" : "Beatrice" then + ARE_B ? "John" : "Julia", + so order must not matter. So, the number of ways + to pick a group of GROUP students out of STUDENTS is + \dfrac{STUDENTS!}{(STUDENTS-GROUP)!GROUP!} = + \binom{STUDENTS}{GROUP}. + [Show me why] +

+
+

+ Remember that the + STUDENTS! \; and (STUDENTS-GROUP)! \; terms come from when we + fill up the group, making STUDENTS + choices for the first slot, then STUDENTS-1 choices for the + second, and so on. In this way, we end up making + _.map(_.range(GROUP), function(l){ return (STUDENTS-l);}).join("\\cdot") + = \dfrac{STUDENTS!}{(STUDENTS-GROUP)!} \;. + The GROUP! \; term comes from the number of times we've counted + a group as different because we chose the students in a different order. + There are GROUP! \; + ways to order a group of GROUP, so for every group, we've overcounted exactly + that many times. +

+
+
+

+ We can use the same logic to count the number of groups that only have ARE_B ? "boys" : "girls". +

+

+ Specifically, the number of ways to pick a group of GROUP students out of + NUM_B is + \dfrac{NUM_B!}{(NUM_B-GROUP)!GROUP!} = + \binom{NUM_B}{GROUP}. +

+

+ So, the probability that the teacher picks a group of all ARE_B ? "boys" : "girls" is the number of + groups with only ARE_B ? "boys" : "girls" divided by the number of total groups the teacher could pick. +

+

+ This is \displaystyle \frac{\frac{NUM_B!}{(NUM_B-GROUP)!\cancel{GROUP!}}} + {\frac{STUDENTS!}{(STUDENTS-GROUP)!\cancel{GROUP!}}} = + \frac{\frac{NUM_B!}{NUM_B-GROUP!}}{\frac{STUDENTS!}{STUDENTS-GROUP!}} +

+

+ We can re-arrange the terms to make simplification easier + \left(\dfrac{NUM_B!}{NUM_B-GROUP!}\right) + \left(\dfrac{STUDENTS-GROUP!}{STUDENTS!}\right) = + \left(\dfrac{NUM_B!}{STUDENTS!}\right) + \left(\dfrac{STUDENTS-GROUP!}{NUM_B-GROUP!}\right) +

+ Simplifying, we get + \left(\dfrac{\cancel{NUM_B!}}{_.map(_.range(STUDENTS-NUM_B), function(l){ return (STUDENTS-l); }).join("\\cdot") + \cdot \cancel{NUM_B!}}\right) + \left(\dfrac{_.map(_.range(STUDENTS-NUM_B), function(l){ return (STUDENTS-GROUP-l); }).join("\\cdot") + \cdot \cancel{(NUM_B-GROUP)!}}{\cancel{NUM_B-GROUP!}}\right) = + \left(\dfrac{1}{factorial(STUDENTS)/factorial(NUM_B)}\right) + \left(factorial(STUDENTS-GROUP)/factorial(NUM_B-GROUP)\right) = + \dfrac{PRETTY_NUM}{PRETTY_DEM} +

+
+
+ +
+
+ randRange(4,7) + randRange(2,COINS-2) + random < 0.5 + IS_H ? "heads" : "tails" + factorial(COINS)/(factorial(NUM)*factorial(COINS-NUM)) + Math.pow(2,COINS) + getGCD(NUM_RIGHT,NUM_ALL) + NUM_RIGHT/GCD + NUM_ALL/GCD +
+ +

+ If you flip a fair coin COINS times, what is the probability that you will get exactly + NUM NAME? +

+

PRETTY_NUMER/PRETTY_DENOM

+ +
+

+ One way to solve this problem is to figure out how many ways you can get exactly NUM NAME, then + divide this by the total number of outcomes you could have gotten. Since every outcome has equal probability, this will be the + probability that you will get exactly + NUM NAME. +

+

+ How many outcomes are there where you get exactly NUM NAME? Try thinking of each outcome as + a COINS-letter word, where the first letter is "H" if the first coin toss was heads and "T" + if it was tails, and so on. +

+

+ So, the number of outcomes with exactly NUM NAME + is the same as the number of these words which have + NUM IS_H ? "H's" : "T's" and COINS-NUM IS_H ? "T's" : "H's". +

+
+

+ How many of these are there? If we treat all the letters as unique, + we'll find that there are COINS! different arrangements, overcounting NUM! + times for every time we only switch the IS_H ? "H's" : "T's" around, and COINS-NUM! + times for every time we only switch the IS_H ? "T's" : "H's" around. + [Show me why] +

+
+ Let's say we toss a coin 5 times, and get tails three times. How many different re-arrangements are there of the + letters "HHTTT"? Well, we have five choices for the first slot, four for the second slot, and so on, resulting in + 5\cdot4\cdot3\cdot2\cdot1 = 5! = 120 \; different re-arrangements. But, this treats all the letters + as unique, when
+ HTHTT + is the same as
+ HTHTT, + and
+ HTHTT, +
+ and so on. So really, we need to replace all these different re-arrangements + where we only move the tails around with one re-arrangement, HTHTT. There are 3! of these multi- + colored arrangements for every normal one, so that means dividing + our first guess of 5! by 3!. By the exact same logic, we need to divide by 2! to + avoid overcounting every permutation where we just move the heads around. So, the number of re-arrangements is + \dfrac{5!}{3!2!} = \binom{5}{3}. +
+
+
+

+ So, there are \dfrac{COINS!}{NUM!COINS-NUM!} = NUM_RIGHT different + outcomes where you get exactly NUM NAME. + [How many total outcomes are there?] +

+
+ Well, if you only flip one coin, there are two outcomes, if you flip two there are four outcomes, if you flip three there + are eight. Each time you flip another coin, you double the number of possible outcomes. +
+
+

+ Altogether, there are 2^{COINS} = NUM_ALL total possible outcomes. +

+

+ So, the probability that you will get exactly NUM NAME is + \dfrac{NUM_RIGHT}{NUM_ALL} = \dfrac{PRETTY_NUMER}{PRETTY_DENOM}. +

+

+ So, the probability that you will get exactly NUM NAME is + \dfrac{NUM_RIGHT}{NUM_ALL}. +

+
+
+
+
+ +
 @@ -43,7 +43,7 @@

This figure is a trapezoid.

 @@ -0,0 +1,151 @@ + + + + + Solutions to quadratic equations + + + +
+
+
+
+ "One rational solution" + randRangeNonZero(-6, 6) * 2 + randFromArray(getFactors(B * B / 4)) + (B * B) / (4 * A) + B * B - 4 * A * C +
+ +

+ Describe the solutions to the following quadratic equation: +

+
+ + expr(["+", + ["*", A, ["^", "x", 2]], + ["*", B, "x"], + C]) + = 0 +
+ +
+
+
• One rational solution
• +
• Two rational solutions
• +
• Two irrational solutions
• +
• One complex solution
• +
• Two complex solutions
• +
+ +
+
+

+ We could use the quadratic formula to solve for the + solutions and see what they are, but there's a + shortcut... +

+

\qquad + x = \dfrac{-b \pm \sqrt{b^2 - 4ac}}{2a} + +

+
+ +
+
+
+

+ Substitute the a, b, and + c coefficients from the quadratic + equation: +

+

+ \qquad\begin{array} + && b^2-4ac \\ \\ + =& B^2 - 4 ( + A)(C) \\ \\ + =& DISCRIMINANT + \end{array} + +

+
+

+ Because \blue{b^2 - 4ac} = 0, then the + quadratic formula reduces to + \dfrac{-b}{2a}, which means there + is just one rational solution. +

+

+ Because \blue{b^2 - 4ac} is negative, its + square is imaginary and the quadratic formula reduces to + \dfrac{-b \pm \sqrt{DISCRIMINANT}}{2a} + , which means there are two complex solutions. +

+

+ Because \blue{b^2 - 4ac} is a perfect + square, its square root is rational and the + quadratic formula reduces to + \dfrac{-b \pm sqrt(DISCRIMINANT)}{2a} + , which means there are two rational solutions. +

+

+ Because \blue{b^2 - 4ac} is not a perfect + square, its square root is irrational and the + quadratic formula reduces to + \dfrac{-b \pm \sqrt{DISCRIMINANT}}{2a} + , which means there are two irrational solutions. +

+
+
+ +
+
+ "Two rational solutions" +
+ randRangeNonZero(-9, 9) + randRangeNonZero(-9, 9) + randRangeNonZero(-9, 9) + B * B - 4 * A * C +
+
+
+ +
+
+ "Two irrational solutions" +
+ randRangeNonZero(-9, 9) + randRangeNonZero(-9, 9) + randRangeNonZero(-9, 9) + B * B - 4 * A * C +
+
+
+ +
+
+ "Two complex solutions" +
+ randRangeNonZero(-9, 9) + randRangeNonZero(-9, 9) + randRangeNonZero(-9, 9) + B * B - 4 * A * C +
+
+
+
+
+ +
3  khan-exercise.js
 @@ -2240,9 +2240,10 @@ var Khan = (function() { agent = navigator.userAgent, mathjaxInfo = "MathJax is " + (typeof MathJax === "undefined" ? "NOT loaded" : ("loaded, " + (MathJax.isReady ? "" : "NOT ") + "ready, queue length: " + MathJax.Hub.queue.queue.length)), + userHash = "User hash: " + crc32(user), sessionStorageInfo = (typeof sessionStorage === "undefined" || typeof sessionStorage.getItem === "undefined" ? "sessionStorage NOT enabled" : null), warningInfo = $("#warning-bar-content").text(), - parts = [$("#issue-body").val() || null, pathlink, historyLink, " " + JSON.stringify(guessLog), agent, sessionStorageInfo, mathjaxInfo, warningInfo], + parts = [$("#issue-body").val() || null, pathlink, historyLink, " " + JSON.stringify(guessLog), agent, sessionStorageInfo, mathjaxInfo, userHash, warningInfo], body =$.grep(parts, function(e) { return e != null; }).join("\n\n"); var mathjaxLoadFailures = \$.map(MathJax.Ajax.loading, function(info, script) {

### No commit comments for this range

Something went wrong with that request. Please try again.