We have a number of 4-foot long pipes that have regular octagonal cross-sections of
various sizes.
We want to place them in a pickup truck which is 4 feet wide, with the length of
each pipe extending across the width of the truck. Each pipe must
rest with one of its 8 sides flat on the truck's bed. The front and
back sides of the
truck are higher than the pipes, so each pipe must fit entirely inside the truck.
How long will the truck have to be to hold them all?
| |
| |
| x x x x |
| x x |
| x x |
| x x x x x |
| x x x x |
| x x x |
| x x x x |
| x x x x x|
| x x x x x x|
| x x x x x x x x x |
|-------------------------------------
<--- length of truck --->
Create a class PickupBed that contains a method length that is given a int[] ht
and returns the minimum length of truck that can hold all the pipes.
The i-th element of ht gives the height of a pipe when it is resting on one of
its sides.
|