# Khan/khan-exercises

1 parent 6edcccd commit 8674af0df8d4293c139573eb156eefcd1d1c3225 bradleyt committed May 26, 2011
Showing with 98 additions and 0 deletions.
1. +64 −0 exercises/arithmetic_word_problems.html
2. +6 −0 utils/math.js
3. +28 −0 utils/word-problems.js
 @@ -0,0 +1,64 @@ + + + + Arithmetic word problems + + + +
+
+ randRange( 3, 12 ) + randRange( 1, ITEMS_PER_GROUP - 1 ) + randRange( 2, 12 ) + GROUPS * ITEMS_PER_GROUP + ITEMS_IN_GROUPS + ITEMS_LEFT + + getRandomFactor( TOTAL_ITEMS ) + TOTAL_ITEMS / NEW_ITEMS_PER_GROUP + +
+ +
+
+

+ person(1) is putting itemPlural(1) into + groupPlural(1). + If he(1) puts + plural( ITEMS_PER_GROUP, item(1), itemPlural(1) ) + in each group(1) he(1) will groupVerb(1) + plural( GROUPS, group(1), groupPlural(1) ) and have + plural( ITEMS_LEFT, item(1), itemPlural(1) ) left over. + If he(1) instead puts + NEW_ITEMS_PER_GROUP itemPlural(1) in each + group(1), how many groupPlural(1) of + itemPlural(1) can he(1) groupVerb(1)? +

+

NEW_GROUPS

+
+
+ +
+

+ plural( GROUPS, group(1), groupPlural(1) ) of + plural( ITEMS_PER_GROUP, item(1), itemPlural(1) ) each results in + GROUPS \times ITEMS_PER_GROUP = ITEMS_IN_GROUPS + itemPlural(1). +

+ +

+ plural( ITEMS_IN_GROUPS, item(1), itemPlural(1) ) plus + ITEMS_LEFT left over equals + TOTAL_ITEMS total itemPlural(1). +

+ +

+ plural( TOTAL_ITEMS, item(1), itemPlural(1) ) + divided into groups of NEW_ITEMS_PER_GROUP is + TOTAL_ITEMS \div NEW_ITEMS_PER_GROUP = NEW_GROUPS + groupPlural(1). + +

+
+ +
 @@ -143,6 +143,12 @@ jQuery.extend(KhanUtil, { return a - b; }); }, + + // Get a random factor of a composite number which is not 1 or that number + getRandomFactor: function( number ) { + var factors = this.getFactors( number ); + return factors[ this.randRange( 1, factors.length - 2 ) ]; + }, getMultiples: function( number, upperLimit ) { var multiples = [];
 @@ -92,6 +92,14 @@ jQuery.fn[ "word-problemsLoad" ] = function() { "\\triangleright" ]); + var collections = KhanUtil.shuffle([ + ["chair", "chairs", "row", "rows", "make"], + ["party favor", "party favors", "bag", "bags", "fill"], + ["jelly bean", "jelly beans", "pile", "piles", "make"], + ["book", "books", "shelf", "shelves", "fill"], + ["can of food", "cans of food", "box", "boxes", "fill"] + ]); + jQuery.extend( KhanUtil, { person: function( i ) { return people[i - 1][0]; @@ -143,6 +151,26 @@ jQuery.fn[ "word-problemsLoad" ] = function() { binop: function( i ) { return binops[i - 1]; + }, + + item: function( i ) { + return collections[i - 1][0]; + }, + + itemPlural: function( i ) { + return collections[i - 1][1]; + }, + + group: function( i ) { + return collections[i - 1][2]; + }, + + groupPlural: function( i ) { + return collections[1 - 1][3]; + }, + + groupVerb: function( i ) { + return collections[i - 1][4]; } }); };