# Khan/khan-exercises

Switch branches/tags
Nothing to show
Fetching contributors…
Cannot retrieve contributors at this time
108 lines (94 sloc) 5.56 KB
 New operator definitions 2
randRange(3, 8) randRange(2, 4) randRange(3, 8) randRange(2, 4) shuffle([ function(C, D, x, y) { return ["+", ["*", C, x], y]; }, function(C, D, x, y) { return ["-", ["*", C, x], y]; }, function(C, D, x, y) { return ["+", x, ["*", C, y]]; }, function(C, D, x, y) { return ["-", x, ["*", C, y]]; }, function(C, D, x, y) { return ["-", ["*", C, x], ["*", D, y]]; }, function(C, D, x, y) { return ["-", ["*", D, x], ["*", C, y]]; }, function(C, D, x, y) { return ["*", x, ["-", y, C]]; }, function(C, D, x, y) { return ["*", ["-", C, x], y]; }, function(C, D, x, y) { return ["+", ["^", x, 2], ["*", D, ["^", y, 2]]]; }, function(C, D, x, y) { return ["+", ["*", D, ["^", x, 2]], ["^", y, 2]]; }, function(C, D, x, y) { return ["-", ["^", x, 2], ["*", D, ["^", y, 2]]]; }, function(C, D, x, y) { return ["-", ["*", D, ["^", x, 2]], ["^", y, 2]]; }, function(C, D, x, y) { return ["-", ["*", D, x], C]; }, function(C, D, x, y) { return ["+", ["*", C, y], D]; }, function(C, D, x, y) { return ["+", ["*", x, y], ["*", D, x], ["-", y]]; } ], 2) !isNaN(expr(FUN1(A, B, 0, NaN), true)) !isNaN(expr(FUN1(A, B, NaN, 0), true)) randRange(-6, 6) randRange(-6, 6) randRange(-6, 6) expr(FUN2(C, D, "x", "y")) expr(FUN2(C, D, Y, Z)) expr(FUN2(C, D, Y, Z), true) expr(FUN1(A, B, "x", "y")) shuffle([ "<code>x " + binop(1) + " y = " + TEXT1 + "</code>", "<code>x " + binop(2) + " y = " + TEXT2 + "</code>" ]).join(" and ")
expr(FUN1(A, B, X, VALU2)) expr(FUN1(A, B, X, VALU2), true) !FUN1_XONLY "left"

If TEXTS, find X binop(1) (Y binop(2) Z).

VALU1

Now, find X binop(1) VALU2:

Find X binop(1) y:

\qquad X binop(1) NEED_VALU1 ? VALU2 : "y" = SUBS1

\qquad \hphantom{X binop(1) VALU2} = VALU1.

\qquad \hphantom{X binop(1) y} = VALU1.

expr(FUN1(A, B, VALU2, X)) expr(FUN1(A, B, VALU2, X), true) !FUN1_YONLY "right"

If TEXTS, find (Y binop(2) Z) binop(1) X.

VALU1

Now, find VALU2 binop(1) X:

Find x binop(1) X:

\qquad NEED_VALU1 ? VALU2 : "x" binop(1) X = SUBS1

\qquad \hphantom{VALU2 binop(1) X} = VALU1.

\qquad \hphantom{x binop(1) X} = VALU1.

First, find Y binop(2) Z:

\qquad Y binop(2) Z = SUBS2

\qquad \hphantom{Y binop(2) Z} = VALU2.

We don't need to find Y binop(2) Z because x binop(1) y depends only on the NEED_VALU1_ONLY operand.