Note to plugin users: There are images in the problem statement and examples. Please use the applet to view them.
You have a piece of wood that you want to use to make the walls of a box that holds jars (shaped as perfect cylinders). The piece of wood is one jar height wide, and the resulting box will only hold one layer of jars. The jars will be placed upright in the box. In order to make the walls of the box, you need to cut the wood into four separate pieces. Each piece needs to be cut such that the four pieces attached at the ends form a rectangle.
To minimize the stress on each jar, you want to pack the jars into the box as tightly as possible, so they are touching as many other jars as possible. The jars in a single row must be horizontally adjacent to each other. However, each successive row must be skewed one radius such that the jars sit exactly between two jars from the previous row to form a hexagonal pattern (Note that this may not be the most efficient space-wise). Here is an example (as viewed from above):
Given the radius, in inches, of the jars that you would like to store, and the woodlength in inches, return the maximum number of jars you can store in a box whose perimeter is at most woodlength inches.
|