## Monday, September 17, 2007

### Primary 5 Maths Question

During 1 week September school holiday, my son (Primary 5) was given a set of maths questions (50 of them) to solve. One of them seems almost clueless but later found out that there is a better way to solve it than a brute force approach.

I am not sure how many of our 11-year old kids can solve this type of question? Or, how many of the teachers can solve this question and manage to explain to the kid until they understand ? Anyway, the question is:

[Q] John bought 3 of the 6 items and Peter bought 2 of the remaining items. John spent twice as much as Peter. Which items did each of them buy ?

 Item 1 Ping-pong bat \$4.70 Item 2 Ping-pong ball \$2.70 Item 3 Shuttlecock \$1.40 Item 4 T-shirt \$3.10 Item 5 Shoes \$7.20 Item 6 Racket \$6.10

Let me take you through my thinking process.

• My first impression is that how on earth can I find a solution using the "model approach" (method to solve a problem without using algebra, it is taught in primary school). I did not spend much time in thinking of the problem because there are 60 combinations to try ( 6C3 * 3C2 ) and it would be too tough to do it manually. Instead, I tapped onto my programming skill to do a "brute force attack" approach to verify an answer(s) exist. This is the Tcl script I wrote:
```package require struct
array set price { 1 4.70 2 2.70 3 1.40 4 3.10 5 7.20 6 6.10 }
proc PriceSum { items } {
global price
set peterSum 0
foreach i \$items {
set peterSum [expr {\$peterSum+\$price(\$i)}]
}
return \$peterSum
}
set all [array names price]
set allN [array size price]
for { set i 1 } { \$i<=\$allN } { incr i } {
for { set j \$i } { \$j<=\$allN } { incr j } {
for { set k \$j } { \$k<=\$allN } { incr k } {
if { \$i == \$j || \$j == \$k || \$i == \$k } { continue }
set john     [list \$i \$j \$k]
set peter012 [struct::set difference \$all \$john]
set peter01  [list [lindex \$peter012 0] [lindex \$peter012 1]]
set peter12  [list [lindex \$peter012 1] [lindex \$peter012 2]]
set peter02  [list [lindex \$peter012 0] [lindex \$peter012 2]]
set peterSum01  [PriceSum \$peter01]
set peterSum12  [PriceSum \$peter12]
set peterSum02  [PriceSum \$peter02]
set johnSumHalf [expr [PriceSum \$john]/2]
if { \$johnSumHalf == \$peterSum01 } {
puts "John: \$john, Peter: \$peter01"
} elseif { \$johnSumHalf == \$peterSum12 } {
puts "John: \$john, Peter: \$peter12"
} elseif { \$johnSumHalf == \$peterSum02 } {
puts "John: \$john, Peter: \$peter02"
}
}
}
}
```
John: 1 4 5, Peter: 6 3

OK, a unique solution does exist. If it is a Primary 5 question, I am sure there is a simplier way to solve it.

• If John bought 3 items and Peter bought 2 items, there will be 1 item left. Ok, may be we can work out the total amount spent by John and Peter and see whether the amount can be divisble by 3, since John spent twice than Peter. Hey, that's the model approach (see model below), isn't it. Great, let's tabulate the result

Model:

John spent
Peter spent

 Item N Total w/o Item N Divisble by 3? 1 \$20.50 No 2 \$22.50 Yes 3 \$23.80 No 4 \$22.10 No 5 \$18.00 Yes 6 \$19.10 No

Now we narrowed down to two possible routes, either item 2 or item 5 is not being bought by John and Peter.

• Case 1: Item 2 not being bought
If John spent twice the amount as Peter, the 10¢ digit of the sum of 3 items has to be an even number (we do not have to work out the exact total). We can ignore it if it is odd.
 John's Items 10¢ digit(sum of John's items) Peter's Items 10¢ digit(sum of Peter's items) Twice ? 1,3,4 2 5,6 3 No 1,3,5 1,3,6 2 4,5 3 No 1,4,5 0 3,6 5 Yes 1,4,6 3,4,5 3,4,6 6 1,5 9 No 4,5,6 4 1,3 1 No
Bingo! John bought Items 1,4,5 and Peter bought items 3 and 6. This tally with my "brute force attack" approach.
• Case 2: Item 5 not being bought
You can repeat the same tabulation but I can tell you that there is no solution.

• Another approach that I can think of. If you look at the cost of the items, the 10¢ digits are basically just 1, 2, 4 and 7. There are only 4 numbers and there won't be a lot of combination to try. If John spent twice as much as Peter, the 10¢ digit sum has to be even, let's tabulate so that we can narrow down our search
 John's items(10¢ digit) Cost of 3 items(10¢ digit) Possible Answer? 1,2,4 7 No 1,2,7 0 Yes (ie, items 5,[12],[4,6]) 1,4,7 2 Yes (ie, items 3,[12],[4,6]) 2,4,7 3 No
Note: [12] means either 1 or 2, in regular expression notation

Another tablulation for John's items

 John's items Sum of 2 items = half of John's (10¢ digit) John=2xPeter? 5,1,4 (\$15.0) \$7.50 = items 3,6 Yes 5,1,6 (\$18.0) \$9.00 = x x 5,2,4 (\$12.0) \$6.00 = x x 5,2,6 (\$16.0) \$8.00 = x x 3,1,4 (\$9.20) \$4.60 = x x 3,1,6 (\$12.2) \$6.10 = x x 3,2,4 (\$7.20) \$3.60 = x x 3,2,6 (\$10.2) \$5.10 = x x

Hope that the teacher and the students read my blog:-)

Labels: ,