Message Boards Message Boards

0
|
4010 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

any idea how to put this list of rectangles?

Posted 10 years ago

How is everybody?, Now I am writing to ask your help to do this. I have this problem, given the following list:

rectangles = {{25,22}, {40,28}, {25,22}, {31,23},{31,23}, {40,28}, {40,28}, {25,22}, {25,22}, {31,23}, {31,23}, {31,23}, {40 28}};

where the first element of each ordered pair is the length of a rectangle and the second element of each ordered pair is the same width rectangle, I need to find a way to place them within a rectangle of 130 long by 100 width, so:

![colocation of rectangles][1]

marked with red rectangles are the {25,22} in green the rectangles {40,28} and finally {31.23} rectangles in yellow, I should mention that should be placed according to the list, I've tried resolving a cycle "while" but also images overlap there are many unnecessary spaces, any idea is welcome, greetings to all.

POSTED BY: Luis Ledesma
3 Replies
Posted 10 years ago

Or a completely different approach.

In[1]:= rectangles={{25,22},{40,28},{25,22},{31,23},{31,23},{40,28},{40,28},{25,22},{25,22},{31,23},{31,23},{31,23},{40,28}};
splitIntoRows[rows_, {}] := rows;
splitIntoRows[rows_,{Longest[row__]/;First[Total[{row}]]<=130,rects___}]:=splitIntoRows[Append[rows,{row}],{rects}];
rows = splitIntoRows[{}, rectangles]

Out[4]= {
{{25, 22}, {40, 28}, {25, 22}, {31, 23}},
{{31, 23}, {40, 28}, {40, 28}},
{{25, 22}, {25, 22}, {31, 23}, {31, 23}},
{{31, 23}, {40, 28}}}

Same study and testing.

POSTED BY: Bill Simpson
Posted 10 years ago
POSTED BY: Bill Simpson
Posted 10 years ago

there any way to do what you ask using the functions, fold, map and apply ? or other functions of mathematica?, hopefully help me finish my problem

POSTED BY: Luis Ledesma
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract