Archis's Blog

October 22, 2011

Rectangle Packing

Filed under: Uncategorized — archisgore @ 2:43 pm

I’m pulling out all the junk stuff I did on my spare time. I promise 100% all the code samples coming out were built on my own time, and boy am I glad to GPLv3 all of them. The latest one, and easiest one to post was a rectangle packing program I was trying out for the DropBox challenge (as part of hiring – considering I worked on Mesh, DropBox seemed like a great company to move to at the time.)

Anyhow, I learnt increasing an order of magnitude for an NP-Hard exponential problem doesn’t help (an N+1 input will kill you anyway.) Couldn’t think of a probabilistic method in the 2 days I spent on it. There’s a couple of optimizations I wasn’t able to do due to the DS I choose. A sparse grid or matrix would have been the right way to go here, but reverting state is difficult on those. The one thing that would speed this up further is to proactively look at the shape of the unfilled area in the candidate box, and find one of the unplaced rectangles that would never fit in that shape. That would trim a large number of candidate boxes fast.

For what it’s worth, here’s the dirty code. More of the BCI signal-processing code to follow over the weekend. Here’s the file: RectanglePacker

About these ads

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 130 other followers

%d bloggers like this: