THE PUZZLET PAGE


PUZZLET 86 - THE SOLUTION



' Puzzlet #086
' The sides of a box are all an exact nr
' of cm (no decimal points), each having
' 2 digits. The height, width, and depth
' are  all different.  The volume is ten
' times the surface area,  which in turn
' is  exactly 31.5 times the sum of  the
' lengths of all twelve edges.
' What are the dimensions of the box?
' By Dave Ellis.

declare PrintIt()
def height, width, depth: int
def volume, area, edgeLength: int

openconsole
print "Searching ...": print

for height = 10 to 97
    for depth = height + 1 to 98
        for width = depth + 1 to 99
            volume = height*width*depth
            area = 2*(height*width + height*depth + width*depth)
            if volume = 10 * area
                edgeLength = 4 * (height + width + depth)
                if area = 31.5*edgeLength
                    PrintIt()
                endif
            endif
        next width
    next depth
next height

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

sub PrintIt
'pretty printer
print "Height:     ", height
print "Width:      ", width
print "Depth:      ", depth
print "Area:       ", area
print "Volume:     ", volume
print "EdgeLength: ", edgeLength
return



PROGRAM NOTES

Each of the box's parameters are given a self-evident variable name: height, width, depth, area, volume, and edgeLength.

Using three nested for-next loops, all possible combinations of three different two digit integers are generated as values for
height, width, and depth.

For each combination, the volume is calculated from the line: 
volume = height*width*depth, then the surface area from the line:  area = 2*(height*width + height*depth + width*depth).

Having obtained the box's area and volume, we can go on to ask the question "Is the volume numerically 10 times the area?"

If the answer is yes, we ask a second, final question: "Is the area 31.5 times the combined edge lengths?"

If this answer is also yes, we've found the solution, and the current variable values are printed out by the subroutine PrintIt().



When you run the program, you'll see the following on your screen.

As required, height, width and depth are all different 2-digit integers. The volume is 10 times the area and the area is 31.5 times the edge length.
 

Searching ...

Height:     42
Width:      84
Depth:      70
Area:       24696
Volume:     246960
EdgeLength: 784

No more!

Press a key ...




Site design/maintenance: Dave Ellis E-mail me!
Last Updated: April 25th, 2004.