# Khan/khan-exercises

### Subversion checkout URL

You can clone with HTTPS or Subversion.

Older
100644 108 lines (106 sloc) 5.188 kb
 b03482a New exercise for triangle inequalities igorT authored Sep 2, 2011 1 2 3 65eec09 Content-Type meta tag for libxml2 compatibility spicyj authored Jan 4, 2012 4 b03482a New exercise for triangle inequalities igorT authored Sep 2, 2011 5 Triangle Inequality Theorem 6 7 22 23 24
25
26 randomTriangleWithSides() 27 rand( 3 ) 28 MAIN[ 1 ][ HIDDEN ] 29 MAIN[ 1 ].slice( 0, HIDDEN ).concat( MAIN[ 1 ].slice( HIDDEN + 1 ) ) 02e2f9c Correct triangle_inequality hints beneater authored Nov 9, 2011 30 roundTo( 1, parseFloat( KNOWN[ 0 ] ) + parseFloat( KNOWN[ 1 ] ) ) 31 roundTo( 1, abs( KNOWN[ 0 ] - KNOWN[ 1 ] ) ) b03482a New exercise for triangle inequalities igorT authored Sep 2, 2011 32
33 34
35
36
26b0aff triangle inequality exercise finished igorT authored Sep 13, 2011 37 What is the range of possible sizes for side x? b03482a New exercise for triangle inequalities igorT authored Sep 2, 2011 38
39
40
41 init({ 4dbb802 polish of geometry igorT authored Sep 16, 2011 42 range: [ [ -1, 10 ], [ -7.5, 1 ] ] b03482a New exercise for triangle inequalities igorT authored Sep 2, 2011 43 }) b52d800 Switching to new 'sides' argument for Triangle, in turn improving for… coffenbacher authored Nov 21, 2011 44 var tr = new Triangle( [ 3, -6.5 ], MAIN[ 0 ], 5, { "sides" : [ HIDDEN !== 2 ? MAIN[ 1 ][ 2 ] : "x", HIDDEN !== 0 ? MAIN[ 1 ][ 0 ] : "x", HIDDEN !== 1 ? MAIN[ 1 ][ 1 ] : "x" ] } ); 4dbb802 polish of geometry igorT authored Sep 16, 2011 45 tr.boxOut( [ [ [ -1, -10 ], [ -1, 10 ] ] ], [ 1, 0 ] ); 46 tr.boxOut( [ [ [ 10, -10 ], [ 10, 10 ] ] ], [ -1, 0 ] ); b03482a New exercise for triangle inequalities igorT authored Sep 2, 2011 47 tr.draw(); 48 tr.drawLabels(); 49
50
51
9ae3477 Answer for triangle_inequality shouldn't be an equality; fixes #4855 beneater authored Nov 8, 2011 52

MIN < x < MAX

53 two exact decimals, like 0.75 b03482a New exercise for triangle inequalities igorT authored Sep 2, 2011 54
55
02e2f9c Correct triangle_inequality hints beneater authored Nov 10, 2011 56

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

57

Therefore the the third side must be less than KNOWN[ 0 ] + KNOWN[ 1 ] = MAX

58

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

59

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

60

So MIN < x < MAX

b03482a New exercise for triangle inequalities igorT authored Sep 2, 2011 61
62
cef3c71 made angle marking appear in similar triangles igorT authored Sep 15, 2011 63
26b0aff triangle inequality exercise finished igorT authored Sep 13, 2011 64
65 randomTriangleWithSides() 66 ( randRange( 0, 1 ) === 0 ) cef3c71 made angle marking appear in similar triangles igorT authored Sep 16, 2011 67
b03482a New exercise for triangle inequalities igorT authored Sep 2, 2011 68
26b0aff triangle inequality exercise finished igorT authored Sep 13, 2011 69 Can this triangle exist? b03482a New exercise for triangle inequalities igorT authored Sep 2, 2011 70
71
9ae3477 Answer for triangle_inequality shouldn't be an equality; fixes #4855 beneater authored Nov 8, 2011 72
b03482a New exercise for triangle inequalities igorT authored Sep 2, 2011 73 init({ 4dbb802 polish of geometry igorT authored Sep 16, 2011 74 range: [ [-1, 10 ], [ -7.5, 1 ] ] b03482a New exercise for triangle inequalities igorT authored Sep 2, 2011 75 }) 26b0aff triangle inequality exercise finished igorT authored Sep 13, 2011 76 if( !POSSIBLE ){ 77 var side = randRange( 0, 2 ); 4dbb802 polish of geometry igorT authored Sep 16, 2011 78 var sideValue = ( parseFloat( MAIN[ 1 ][ ( side + 1 ) % 3 ] ) + parseFloat( MAIN[ 1 ][ ( side + 2 ) % 3 ] ) + randRange( 1, 3 ) ).toFixed( 1 ); 26b0aff triangle inequality exercise finished igorT authored Sep 13, 2011 79 MAIN[ 1 ][ side ] = sideValue; 80 } b52d800 Switching to new 'sides' argument for Triangle, in turn improving for… coffenbacher authored Nov 22, 2011 81 var tr = new Triangle( [ 3, -6.9 ], MAIN[ 0 ], 5, { "sides" : [ MAIN[ 1 ][ 2 ], MAIN[ 1 ][ 0 ], MAIN[ 1 ][ 1 ] ] } ); 4dbb802 polish of geometry igorT authored Sep 16, 2011 82 tr.boxOut( [ [ [ -1, -10 ], [ -1, 10 ] ] ], [ 1, 0 ] ); 83 tr.boxOut( [ [ [ 10, -10 ], [ 10, 10 ] ] ], [ -1, 0 ] ); b03482a New exercise for triangle inequalities igorT authored Sep 2, 2011 84 tr.draw(); 85 tr.drawLabels(); 86
87
26b0aff triangle inequality exercise finished igorT authored Sep 13, 2011 88
POSSIBLE ? "Yes" : "No"
89
90
• Yes
• 91
• No
• 92
b03482a New exercise for triangle inequalities igorT authored Sep 2, 2011 93
26b0aff triangle inequality exercise finished igorT authored Sep 13, 2011 94

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

70a19b7 Typo fix in triangle inequality coffenbacher authored Nov 21, 2011 95

Let's check for all three sides:

26b0aff triangle inequality exercise finished igorT authored Sep 13, 2011 96
9ae3477 Answer for triangle_inequality shouldn't be an equality; fixes #4855 beneater authored Nov 8, 2011 97

MAIN[ 1 ][ i ] + MAIN[ 1 ][ ( i + 1 ) % 3 ] = ( parseFloat( MAIN[ 1 ][ i ] ) + parseFloat( MAIN[ 1 ][ ( i + 1 ) % 3 ] ) ).toFixed( 1 )

98

MAIN[ 1 ][ ( i + 2 ) % 3 ] is not smaller than ( parseFloat( MAIN[ 1 ][ i ] ) + parseFloat( MAIN[ 1 ][ ( i + 1 ) % 3 ] ) ).toFixed( 1 ) so the theorem does not holdholds.

26b0aff triangle inequality exercise finished igorT authored Sep 13, 2011 99
100

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

101

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

b03482a New exercise for triangle inequalities igorT authored Sep 2, 2011 102
103
104
8531c06 triangle_inequality fixes spicyj authored Sep 3, 2011 105
b03482a New exercise for triangle inequalities igorT authored Sep 2, 2011 106 107
Something went wrong with that request. Please try again.