Home > dbc1

dbc1

Dbc1 is a project mainly written in ..., it's free.

Dropbox Challenge 1

Dropbox Challenge 1

The bounding rectangle problem is NP-Hard

When you're working with petabytes of data, you have to store files wherever they can fit. All of us here at Dropbox are always searching for more ways to efficiently pack data into smaller and more manageable chunks. The fun begins when you bend the rules a little bit and visualize it in two dimensions.

You'll be given a list of rectangular "files" that you'll need to pack into as small a "Dropbox" as possible. The dimensions of each file will be specified by a tuple (width, height), both of which will be integers. The output of your function should be the area of the smallest rectangular Dropbox that can enclose all of them without any overlap. Files can be rotated 90° if it helps. Bonus points if you can draw pictures of the winning configurations along the way. While drawing pictures, any files sharing dimensions should be considered identical/interchangeable.

Input Your program must read a small integer N (1 <= N <= 100) from STDIN representing the maximum number of files to consider, followed by the width and height of each file, one per line.

Output Output should be simply be the area of the smallest containing Dropbox. If you want to print pretty pictures, send that to stderr. Only the output on stdout will be judged.

Previous:Publ.ca