forked from alxsoares/topcoder-6
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoxLoader.html
More file actions
6 lines (5 loc) · 4.98 KB
/
Copy pathBoxLoader.html
File metadata and controls
6 lines (5 loc) · 4.98 KB
1
2
3
4
5
6
<html><head><title>BoxLoader</title></head><body ><table><tr><td colspan="2"><h3>Problem Statement</h3></td></tr><tr><td>    </td><td><p>Your company has a new box loading robot. It is your job to program it to pack items into the shipping boxes. The robot does not have a very large program memory so you are restricted to placing all the items into the boxes in the same orientation. Each item is a rectangular solid with dimensions <b>itemX</b> by <b>itemY</b> by <b>itemZ</b>. The box is also rectangular with the dimensions <b>boxX</b> by <b>boxY</b> by <b>boxZ</b>. The items can be placed in the box in any orthogonal orientation (ie. the sides of the items must be parallel to the sides of the box), but only whole items can be placed in the box.
Your task here is to determine the greatest number of items that can be packed into the box (with all the items in the same orientation).</p>
<p>
For example, if the box is 100x98x81 units and the items are 3x5x7 units, then orienting the items so they are 5x7x3, allows them to fit in the box in a 20x14x27 grid, filling the entire box, which is optimal: 7560 items.</p></td></tr><tr><td colspan="2"><h3>Definition</h3></td></tr><tr><td>    </td><td><table><tr><td>Class:</td><td>BoxLoader</td></tr><tr><td>Method:</td><td>mostItems</td></tr><tr><td>Parameters:</td><td>int, int, int, int, int, int</td></tr><tr><td>Returns:</td><td>int</td></tr><tr><td>Method signature:</td><td>int mostItems(int boxX, int boxY, int boxZ, int itemX, int itemY, int itemZ)</td></tr><tr><td colspan="2">(be sure your method is public)</td></tr></table></td></tr><tr><td>    </td></tr><tr><td></td></tr><tr><td colspan="2"><h3>Notes</h3></td></tr><tr><td align="center" valign="top">-</td><td>There are six possible orientations for an item.</td></tr><tr><td colspan="2"><h3>Constraints</h3></td></tr><tr><td align="center" valign="top">-</td><td><b>boxX</b>, <b>boxY</b> and <b>boxZ</b> will be between 1 and 1000 inclusive.</td></tr><tr><td align="center" valign="top">-</td><td><b>itemX</b>, <b>itemY</b> and <b>itemZ</b> will be between 1 and 1000 inclusive.</td></tr><tr><td colspan="2"><h3>Examples</h3></td></tr><tr><td align="center" nowrap="true">0)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>100</pre></td></tr><tr><td><pre>98</pre></td></tr><tr><td><pre>81</pre></td></tr><tr><td><pre>3</pre></td></tr><tr><td><pre>5</pre></td></tr><tr><td><pre>7</pre></td></tr></table></td></tr><tr><td><pre>Returns: 7560</pre></td></tr><tr><td><table><tr><td colspan="2">The example from above.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">1)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>10</pre></td></tr><tr><td><pre>10</pre></td></tr><tr><td><pre>10</pre></td></tr><tr><td><pre>9</pre></td></tr><tr><td><pre>9</pre></td></tr><tr><td><pre>11</pre></td></tr></table></td></tr><tr><td><pre>Returns: 0</pre></td></tr><tr><td><table><tr><td colspan="2">That's not going to fit!</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">2)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>201</pre></td></tr><tr><td><pre>101</pre></td></tr><tr><td><pre>301</pre></td></tr><tr><td><pre>100</pre></td></tr><tr><td><pre>30</pre></td></tr><tr><td><pre>20</pre></td></tr></table></td></tr><tr><td><pre>Returns: 100</pre></td></tr><tr><td><table><tr><td colspan="2">There is going to be some empty space in this box, as none of the box dimensions is an exact multiple of an item dimension. Orienting the items so that the 30 unit dimension goes in the box's 301 unit direction wastes the
least space. 10 items can fit leaving only one unit of waste in that dimension.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">3)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>913</pre></td></tr><tr><td><pre>687</pre></td></tr><tr><td><pre>783</pre></td></tr><tr><td><pre>109</pre></td></tr><tr><td><pre>93</pre></td></tr><tr><td><pre>53</pre></td></tr></table></td></tr><tr><td><pre>Returns: 833</pre></td></tr><tr><td><table><tr><td colspan="2">A less obvious example of minimizing the wasted space.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">4)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>6</pre></td></tr><tr><td><pre>5</pre></td></tr><tr><td><pre>4</pre></td></tr><tr><td><pre>3</pre></td></tr><tr><td><pre>2</pre></td></tr><tr><td><pre>1</pre></td></tr></table></td></tr><tr><td><pre>Returns: 20</pre></td></tr><tr><td></td></tr></table></td></tr></table><p>This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved. </p></body></html>