Promising them an increase in their allowance if they get the answer, I offer my two sons, Peter and Paul, the following puzzler:
"I am thinking of a rectangle with integer sides, each of which are greater than one inch. The total perimeter of the rectangle is no greater than eighty inches."
I then whisper the total area to Peter and the total perimeter to Paul. Neither of them are allowed to tell the other what they heard: their job is to work out the rectangle's dimensions.
Their subsequent conversation goes like this:
Peter: Hmmm... I have no idea what the perimeter is.
Paul: I knew you were going to say that. However, I don't know what the area is.
Peter: Still no clue as to the perimeter...
Paul: But now I know what the area is!
Peter: And I know what the perimeter is!
What are the dimensions of the rectangle?
(In reply to
Answer + Solution by nikki)
Nikki,
My program is getting the answer: perimeter = area = 16 (4x4 rectangle). Maybe you can see where I'm going wrong, if I am going wrong. (I may be stumbling over that subtle hint "I knew you were going to say that" by Paul).
The program logic is:
Generate two tables: one with every possible area, along with all the perimeters that are associated with it; and one with every possible perimeter (from 8 to 80) along with every possible area associated with it.
After the first statement (Peter doesn't know the perimeter), eliminate every row on the area table that does not have multiple perimeter references.
After the second statement (Paul doesn't know the area), zero out every area references on the perimeter table that does not have a corresponding row on the area table; then eliminate every row of the perimeter table that does not have multiple area references.
After the third statement (Peter doesn't know the perimeter), zero out every perimeter references on the area table that does not have a corresponding row on the perimeter table; then eliminate every row of the area table that does not have multiple perimeter references.
After the fourth statement (Paul now knows the area), zero out every area references on the perimeter table that does not have a corresponding row on the area table; then eliminate every row of the perimeter table except for those with only one area references.
After the fifth statement (Peter now knows the perimeter), zero out every perimeter references on the area table that does not have a corresponding row on the perimeter table; then eliminate every row of the area table except for those with only one perimeter references.
This produces perimeter = 16 and area = 16 on both tables.
|
Posted by Penny
on 2005-01-29 14:48:20 |