THE PUZZLET PAGE


PUZZLET 81 - THE SOLUTION

From the inset sketch, you can see that the overall width of the cardboard before cutting is going to be:

width + 2 x height.

Similarly, the overall depth of the cardboard before cutting is going to be:

depth + 2 x height.

The total area of the cardboard before cutting is going to be original width x original height, which equals:

(width + 2 x height) x (depth + 2 x height).

The volume of the resultant box is simply:

width x height x depth.
   
Cardboard

Now we've made a simple analysis, there's enough information to write some code.

' Puzzlet #081
' A box is made by cutting the corners
' from a rectangle of cardboard,  then
' folding the remaining shape upwards.
' All  sides of the box are  different 
' 2-digit integers. The box's width is
' less than its height,  and the depth
' is greater than the height. Its vol-
' ume is numerically twice the area of
' cardboard that existed before  those
' corners were lopped off. 
' What are the box's dimensions?
' By Dave Ellis.

declare PrintResult()
def area: int
def volume: int
def wide: int
def high: int
def deep: int

openconsole
print "Searching ...": print
print"Width Height Depth  Area  Volume"
print

for wide = 10 to 97
  for high = wide + 1 to 98
    for deep = high + 1 to 99
      area = (wide + 2*high)*(deep + 2*high)
      volume = wide * high * deep
      if volume = 2 * area
        PrintResult()
      endif
    next deep
  next high
next wide

print: print "No more!"
print: print "Press any key to exit ... ",
do: until inkey$ <> ""
closeconsole
end

sub PrintResult
' pretty printer
print using ("####", wide), 
print using ("######", high), 
print using ("######", deep), 
print using ("########", area), 
print using ("#######", volume)
return

PROGRAM NOTES

The main routine generates every possible combination of three different 2-digit integers. This is accomplished using three nested FOR-NEXT loops, with variables wide, high, and deep as iterators.

For each combination, the cardboard's original area and the resultant box's volume are calculated using the simple formulae developed with the sketch above.

If the volume turns out to be exactly twice the area, the result is printed to the computer screen by calling subroutine PrintResult().

That's all there is to this little program!



The inset screen shot shows the result of running the code above.

As you can see, there are three  solutions in all.
   
             
Searching ...

Width Height Depth  Area  Volume

  10    20    40    4000   8000
  10    45    72   16200  32400
  12    30    40    7200  14400

No more!

Press any key to exit ...



Site design/maintenance: Dave Ellis E-mail me!
Last Updated: March 21st, 2004.