No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Pack the Box.

You have a container. Given a series of items of the same size and shape, what space efficiency can be achieved by randomly selecting an x,y coordinate at which to place each item inside the container?

  • Is efficiency greater or smaller when items are smaller?
  • What shapes fare better than others?
  • Does the size of the container matter?

Test your hypotheses, and see how efficient your outcomes can be.

User Input Defaults Default Results

Getting Started

These instructions will get you a copy of the project up and running on your local machine.

PREREQUISITES: The algorithm is built to run with Python 3. The Turtle graphics library executes the drawing functions to visualize the spatial outcome. Turtle uses tkinter for its graphics, so be sure to install a version of Python with Tk support.

Testing Your Hypotheses

A few instructions to start testing your hypotheses:

Clone the git repository.

Run the file and input your initial container dimensions.

What is the height of your container? default:600 >>>
What is the width of your container? default:500 >>>

The shape of the item is randomized between a rectangle or a circle. Enter your desired dimensions, depending on the shape.

What is the desired height/width of your rectangle? default:40,90 >>>
What is the desired radius of your circle? default:40 >>>

The script will execute based on these parameters and the random placement of items in the container. At the end, the spatial efficiency value is returned.

Circles Results


The current solution's wost-case runtime is


This is because the program checks every existing item in the container before determining whether the current x,y coordinate would cause overlap. An additional runtime of n*(LOOP_LIMIT-1) should be considered in case the max number of placement attempts happens to have been exceeded for every single item added.


  • Therese Diede - Software Engineer