This may not be a question all about Perl, but ya'll are the smartest people I know, so I was hoping someone could help me through this.
I have a double array of rectangles. Each rectangle has an x and a y coordinate. I have an area of MaxX by MaxY to be filled. Lets just say I am trying to fit these rectangles on an 8.5 by 11 piece of paper. So MaxX = 8.5 and MaxY = 11. I have to have a line that divides the paper in two. This line can be either vertical or horizontal.
These rectangles can be turned either way, so we do not have to worry about x's and y's. My priorities are to have the largest area taken, and to hopefully go from one edge of the paper to the other, without having any scrap. For example, there are 4, 2.75 by 3 rectangles and 4, 3 by 3 rectangles. I would want to use the 4, 2.75 by 3 rectangles because the height of all of the rectangles stacked up is 11, thus we can have a solid line vertically with zero scrap. So I am looking to find the largest area with the least amount of scrap. If there are two possibilites that have zero scrap, then the one with the largest area will be the one chosen. If there are none with zero scrap, then the one with the least amount of scrap will be chosen. If there is a tie between ones with the least amount of scrap, then the one with the largest amount of area will be chosen.
That is my problem, I am looking for as much help as possible. I really do not know how to loop through the array and choose the best one, and then look through again looking to see if there is a better one. I hope that this is not confusing and that someone can help. Thanks in advance.
janitored by ybiC: Retitle from "Grasping the concept"
In reply to Knapsack problem by stu96art
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |