randRange(1, 6) randRange(A + 1, 10) B - A randFromArray([ ["Spunky Sam", "/images/avatars/spunky-sam.png"], /* ["Marcimus", "/images/avatars/marcimus.png"], */ ["Mr. Pink", "/images/avatars/mr-pink.png"], ["Orange Juice Squid", "/images/avatars/orange-juice-squid.png"], ["Purple Pi", "/images/avatars/purple-pi.png"], ["Pants", "/images/avatars/mr-pants.png"], ["Old Spice Man", "/images/avatars/old-spice-man.png"], ])

How much does UNKNOWN weigh?

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 desc1 = "You"; var leftOp = ""; var rightOp = ""; if (a - A < 0) { desc1 += " <span class='hint_blue'>subtracted " + abs(a - A) + " from the left side</span>"; leftOp = " \\blue{- " + abs(a - A) + "}" } else if (a - A > 0) { desc1 += " <span class='hint_blue'>added " + abs(a - A) + " to the left side</span>"; leftOp = " \\blue{+ " + abs(a - A) + "}" } if (a - A !== 0 && b - B !== 0) { desc1 += " and"; } if (b - B < 0) { desc1 += " <span class='hint_green'>subtracted " + abs(b - B) + " from the right side</span>"; rightOp = " \\green{- " + abs(b - B) + "}" } else if (b - B > 0) { desc1 += " <span class='hint_green'>added " + abs(b - B) + " to the right side</span>"; rightOp = " \\green{+ " + abs(b - B) + "}" } if (a - A === 0 && b - B === 0) { desc1 = "You haven't added or removed " + "anything from either side, so we can't " + "directly tell what " + UNKNOWN + "'s " + "weight is from the equation."; $("#description2").parent().hide(); } else { desc1 += ":"; $("#description2").text("\\qquad x + " + A + leftOp + (a - A === b - B ? " \\quad=\\quad " : " \\quad\\ne\\quad ") + B + rightOp); $("#description2").parent().show(); } $("#description1").html(desc1); if (a - A === b - B) { if (a - A !== 0) { if (a === 0) { $("#description3").html("Simplifying, we " + "can see " + UNKNOWN + "'s weight:"); $("#description4").text( "\\qquad x \\quad=\\quad " + X); } else { $("#description3").html("Simplifying, we " + "still can't directly see " + UNKNOWN + "'s weight:"); $("#description4").text( "\\qquad x + " + a + " \\quad=\\quad " + b); } $("#description3").show() $("#description4").parent().show(); } else { $("#description3").hide() $("#description4").parent().hide(); } } else { $("#description3").html("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."); $("#description3").show() $("#description4").parent().hide(); } MathJax.Hub.Queue(["Reprocess", MathJax.Hub, $("#description2")[0]]); MathJax.Hub.Queue(["Reprocess", MathJax.Hub, $("#description4")[0]]); }; scale.init({ unknown: X, leftConst: A, rightConst: B, image: IMAGE });

reset

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

Balance the scale with UNKNOWN alone on one side and enter the weight:

[ $("input#answer").val(), scale.leftConst, scale.rightConst ]
if (guess[0] === "") { return ""; } if (guess[1] !== 0) { return "Make sure " + UNKNOWN + " is alone on " + "one side of the scale."; } if (guess[1] + X !== guess[2]) { return "Make sure the scale is balanced."; } return +guess[0] === X;
scale.setLeftWeight(guess[1]); scale.setRightWeight(guess[2]);
$("input#answer").val(guess[0]);