The Universe of Disco


Sun, 08 Jan 2006

How long is the banana?

Mark Dominus:
One of the types of problems that al-Khwarizmi treats extensively in his book is the problem of computing inheritances under Islamic law.

Well, these examples are getting sillier and sillier, but

... but maybe they're not silly enough:

A rope over the top of a fence has the same length on each side and weighs one-third of a pound per foot. On one end of the rope hangs a monkey holding a banana, and on the other end a weight equal to the weight of the monkey. The banana weighs 2 ounces per inch. The length of the rope in feet is the same as the age of the monkey, and the weight of the monkey in ounces is as much as the age of the monkey's mother. The combined ages of the monkey and its mother is 30 years. One-half the weight of the monkey plus the weight of the banana is one-fourth the sum of the weights of the rope and the weight. The monkey's mother is one-half as old as the monkey will be when it is three times as old as its mother was when she was one-half as old as the monkey will be when it is as old as its mother will be when she is four times as old as the monkey was when it was twice as old as its mother was when she was one-third as old as the monkey was when it was as old as its mother was when she was three times as old as the monkey was when it was one-fourth as old as its is now. How long is the banana?

(Spoiler solution using, guess what, Linogram....)


        define object {
          param number density;
          number length, weight;
          constraints { density * length = weight; }
          draw { &dump_all; }
        }

        object banana(density = 24/16), rope(density = 1/3);
        number monkey_age, mother_age;
        number monkey_weight, weight_weight;

        constraints { 
          monkey_weight * 16 = mother_age;
          monkey_age + mother_age = 30;
          rope.length = monkey_age;
          monkey_weight / 2 + banana.weight  = 
                1/4 * (rope.weight + weight_weight);
          mother_age = 1/2 * 3 * 1/2 * 4 * 2 * 1/3 * 3 * 1/4 * monkey_age;
          monkey_weight = weight_weight;
        }

        draw { banana; }

        __END__

        use Data::Dumper;
        sub dump_all {
          my $h = shift;
          print Dumper($h);
        #  for my $var (sort keys %$h) {
        #    print "$var = $h->{$var}\n";
        #  }
        }

OK, seriously, how often do you get to write a program that includes the directive draw { banana; }?

The output is:

        $VAR1 = bless( {
                         'length' => '0.479166666666667',
                         'weight' => '0.71875',
                         'density' => '1.5'
                       }, 'Environment' );

So the length of the banana is 0.479166666666667 feet, which is 5.75 inches.


[Other articles in category /linogram] permanent link