Packing rectangles into a rectangle

published on January 18, 2015 in Tips and Tricksno comments
Packing rectangles into a rectangle Once, I have been given the following task: make a JavaScript plugin that allows to fit a variable number of rectangles of different sizes into another rectangle. Or better, you have a variable number of surfaces to cover with iron, iron is provided¬†in panels of size¬†depending on the factory: calculate the minimum number of panels that you need to fulfill the request. In this calculation, you need to include a margin between the rectangles as well – that corresponds to the line of cut. It was a quite interesting challenge. Finding the perfect algorithm in a short time was quite... read more »