2004-08-25

7th Grade Math Fun

A farmer has a $100 tax refund check. He wants to buy 100 animals and have some of each kind. Cows are $1.00, sheep are $0.50, and horses are $10.00. Obviously, we have 3 variables, the number of cows, sheep and horses. Unfortunately, we only have two equations:

s(0.50) + c(1.00) + h(10.00) = 100.00 [1] s + c + h = 100 [2],

where s is the number of sheep, c is the number of cows, and h is the number of horses. With this lack of information regarding the 3rd equation we know there will be multiple answers. Not being one for guessing I wrote this program

#!/usr/bin/perl use strict; use warnings; my $cow = 1; # cows for a buck my $sheep = .5; # sheep for fifty my $horse = 10; # horses for ten for (my $c=1; $c<=100; $c++) { # cows for (my $s=1; $s<=100; $s++) { # sheep for (my $h=1; $h<=100; $h++) { # horses my $cost = $c$cow + $s$sheep + $h*$horse; my $count = $c + $s + $h; if ( $cost == 100 && $count == 100 ) { print “Cows: $c; Sheep: $s; Horses: $hn”; } } } }

and found

Cows: 5; Sheep: 90; Horses: 5 Cows: 24; Sheep: 72; Horses: 4 Cows: 43; Sheep: 54; Horses: 3 Cows: 62; Sheep: 36; Horses: 2 Cows: 81; Sheep: 18; Horses: 1

So how is a 7th grader, who doesn’t know algebra or programming, supposed to figure this out? Did I miss something obvious?

Comments are closed.