randomTriangleWithSides() rand(3) (function() { var known = MAIN[1].slice(); known.splice(HIDDEN, 1); return _.map(known, function(v) { return roundTo(1, v); }); })() _.map(KNOWN, function(v) { return localeToFixed(v, 1); }) roundTo(1, KNOWN[0] + KNOWN[1]) localeToFixed(MAX, 1) roundTo(1, abs(KNOWN[0] - KNOWN[1])) localeToFixed(MIN, 1)
What is the range of possible sizes for side x?
init({ range: [ [ -1, 10 ], [ -7.5, 1 ] ] }); var positionMap = {0: 2, 1: 0, 2: 1}; var sides = _.times(3, function(i) { if (positionMap[i] === HIDDEN) { return "x"; } else { return localeToFixed(MAIN[1][positionMap[i]], 1); } }); var tr = new Triangle( [ 3, -6.5 ], MAIN[ 0 ], 5, { "sides" : sides } ); tr.boxOut( [ [ [ -1, -10 ], [ -1, 10 ] ] ], [ 1, 0 ] ); tr.boxOut( [ [ [ 10, -10 ], [ 10, 10 ] ] ], [ -1, 0 ] ); tr.draw(); tr.drawLabels();

MIN < x < MAX

The triangle inequality theorem states that any side of a triangle is always shorter than the sum of the other two sides.

Therefore the third side must be less than KNOWN_DISPLAY[ 0 ] + KNOWN_DISPLAY[ 1 ] = MAX_DISPLAY

By the same theorem, the third side must be also larger than the difference between the other two sides.

Therefore the third side must be larger than KNOWN[0] < KNOWN[1] ? KNOWN_DISPLAY[1] : KNOWN_DISPLAY[0] - KNOWN[0] < KNOWN[1] ? KNOWN_DISPLAY[0] : KNOWN_DISPLAY[1] = MIN_DISPLAY

So MIN_DISPLAY < x < MAX_DISPLAY

randRange( 0, 1 ) === 0 randRange(0, 2) MAIN[1][(SIDE + 1) % 3] + MAIN[1][(SIDE + 2) % 3] + randRange(1, 3) _.map((function() { if (POSSIBLE) { return MAIN[1]; } else { var m = MAIN[1].slice(); m.splice(SIDE, 1, FAKE_SIDE); return m; } })(), function(v) { return roundTo(1, v); }) _.map(FAKE_SIDES, function(v) { return localeToFixed(v, 1); }) [$._("Yes"), $._("No")] [ [FAKE_SIDES_DISPLAY[0], FAKE_SIDES_DISPLAY[1], FAKE_SIDES_DISPLAY[2], localeToFixed(FAKE_SIDES[1] + FAKE_SIDES[2], 1), FAKE_SIDES[0] < FAKE_SIDES[1] + FAKE_SIDES[2]], [FAKE_SIDES_DISPLAY[1], FAKE_SIDES_DISPLAY[0], FAKE_SIDES_DISPLAY[2], localeToFixed(FAKE_SIDES[0] + FAKE_SIDES[2], 1), FAKE_SIDES[1] < FAKE_SIDES[0] + FAKE_SIDES[2]], [FAKE_SIDES_DISPLAY[2], FAKE_SIDES_DISPLAY[0], FAKE_SIDES_DISPLAY[1], localeToFixed(FAKE_SIDES[0] + FAKE_SIDES[1], 1), FAKE_SIDES[2] < FAKE_SIDES[0] + FAKE_SIDES[1]] ]
Can this triangle exist?
init({ range: [ [-1, 10 ], [ -7.5, 1 ] ] }) var tr = new Triangle( [ 3, -6.9 ], MAIN[ 0 ], 5, { "sides" : [ FAKE_SIDES_DISPLAY[ 2 ], FAKE_SIDES_DISPLAY[ 0 ], FAKE_SIDES_DISPLAY[ 1 ] ] } ); tr.boxOut( [ [ [ -1, -10 ], [ -1, 10 ] ] ], [ 1, 0 ] ); tr.boxOut( [ [ [ 10, -10 ], [ 10, 10 ] ] ], [ -1, 0 ] ); tr.draw(); tr.drawLabels();
ANSWERS[POSSIBLE ? 0 : 1]
  • ANS

Triangle inequality theorem states that a side must be smaller than the sum of the other two sides.

Let's check for all three sides:

SET[1] + SET[2] = SET[3]

SET[0] is smaller than SET[3] so the theorem holds.

SET[0] is not smaller than SET[3] so the theorem does not hold.

All three sides conform to the inequality theorem, so this triangle can exist.

Not all three sides conform to the inequality theorem, so this triangle cannot exist.