How much does UNKNOWN weigh?
KhanUtil.scale.onChange = function(leftCoef, a, rightCoef, b) {
$("#sub-left").prop("disabled", a === 0);
$("#add-left").prop("disabled", a === 10);
$("#sub-right").prop("disabled", b === 0);
$("#add-right").prop("disabled", b === 10);
var leftOp = "";
var rightOp = "";
var leftOpSign = (a - A > 0) ? "+" : "-";
var rightOpSign = (b - B > 0) ? "+" : "-";
$(".desc-a").text(abs(a - A));
$(".desc-b").text(abs(b - B));
$("#description1").children().hide();
$("#description2").parent().show();
var desc2Text = "";
var desc4Text = "";
if (a - A !== 0 && b - B !== 0) {
leftOp = " \\blue{" + leftOpSign + abs(a - A) + "}";
rightOp = " \\green{" + rightOpSign + abs(b - B) + "}"
if (a - A < 0 && b - B < 0) {
$("#description1 .opt-1").show();
} else if (a - A < 0 && b - B > 0) {
$("#description1 .opt-2").show();
} else if (a - A > 0 && b - B < 0) {
$("#description1 .opt-3").show();
} else if (a - A > 0 && b - B > 0) {
$("#description1 .opt-4").show();
}
} else if (a - A !== 0) {
leftOp = " \\blue{" + leftOpSign + abs(a - A) + "}";
if (a - A < 0) {
$("#description1 .opt-5").show();
} else if (a - A > 0) {
$("#description1 .opt-6").show();
}
} else if (b - B !== 0) {
rightOp = " \\green{" + rightOpSign + abs(b - B) + "}"
if (b - B < 0) {
$("#description1 .opt-7").show();
} else if (b - B > 0) {
$("#description1 .opt-8").show();
}
} else {
$("#description1 .opt-none").show();
$("#description2").parent().hide();
}
desc2Text =
"\\qquad x + " + A + leftOp +
(a - A === b - B ?
" \\quad=\\quad " :
" \\quad\\neq\\quad ") +
B + rightOp;
$("#description3").children().hide();
if (a - A === b - B) {
if (a - A !== 0) {
if (a === 0) {
$("#description3 .opt-done").show();
desc4Text = "\\qquad x \\quad=\\quad " + X;
} else {
$("#description3 .opt-notdone").show();
desc4Text = "\\qquad x + " + a +
" \\quad=\\quad " + b;
}
$("#description3").show()
$("#description4").parent().show();
} else {
$("#description3").hide()
$("#description4").parent().hide();
}
} else {
$("#description3 .opt-different").show();
$("#description3").show()
$("#description4").parent().hide();
}
KhanUtil.processMath($("#description2")[0], desc2Text, true);
KhanUtil.processMath($("#description4")[0], desc4Text, true);
};
// TODO(emily): make this faster (don't re-init every time)
KhanUtil.scale.init({
unknown: X,
leftConst: A,
rightConst: B,
image: Khan.imageBase + "avatars/" + AVATAR
});
This is algebra?
Yep! We can represent the problem with an equation if
we let the letter x
represent
UNKNOWN's weight:
\qquad x + A \quad=\quad B
You
subtracted
A
from the left side
and
subtracted
B
from the right side:
You
subtracted
A
from the left side
and
added
B
to the right side:
You
added
A
to the left side
and
subtracted
B
from the right side:
You
added
A
to the left side
and
added
B
to the right side:
You
subtracted
A
to the left side:
You
added
A
to the left side:
You
subtracted
B
from the right side:
You
added
B
to the right side:
You haven't added or removed
anything from either side, so we can't directly
tell what UNKNOWN's weight is from the
equation.
Simplifying, we can see UNKNOWN's weight:
Simplifying, we still can't directly see
UNKNOWN's weight:
Since you did something different to each side of
the equation, the left and right side are no longer
equal and you can't tell what UNKNOWN's
weight is.
[
$("input#answer").val(),
KhanUtil.scale.leftConst,
KhanUtil.scale.rightConst
]
if (guess[0] === "") {
return "";
}
if (guess[1] !== 0) {
return $._("Make sure %(name)s is alone on " +
"one side of the scale.", {name: UNKNOWN});
}
if (guess[1] + X !== guess[2]) {
return $._("Make sure the scale is balanced.");
}
return +guess[0] === X;
KhanUtil.scale.setLeftWeight(guess[1]);
KhanUtil.scale.setRightWeight(guess[2]);
$("input#answer").val(guess[0]);