Put the presents in their boxes!

Hi everyone!
I have a very interesting challenge for you!
(or at least I hope you’ll see it this way because I’m in a dead end and I need some help hehehe)

I have a series of random sized boxes (presents - green ones) and 3 fixed sized boxes (red ones)
What I’m trying to do is correspond each ‘present’ to the smallest possible ‘box’ it can fit in.
but there is a catch: the ‘presents’ need not be upright in the boxes.

In my mind, the algorithm should order the three dimensions of the presents and find the smallest possible of the boxes whose three dimensions (from big to small) are bigger than (or equal to) the corresponding ordered dimensions of the present.
that should be a watertight algorithm right?
problem is I’ve been struggling for a few hours so far and I go around in circles…

  • what I’m looking for, is just a list that tells me how many times each type of box is needed. no need to know which present it corresponds to .

presents.gh (9.4 KB) presents

Hi,

might this be a solution?

presents_RE.gh (18.7 KB)

1 Like

I just downloaded it to go through it but it seems like you did it!
(and I like the animation as well!)
you’re the man!

EDIT: you are not the man! (hahaha, just teasing you)
you missed the most important part: you are allowed to ‘turn’ a present to fit to a box.
we are not comparing x,y,z dimensions. We want to compare the dimensions from bigger to smaller.

I think I’m almost there…
for each path in the final tree, the box used is the first ‘true’ in the list.
(here we are comparing 3 presents against 5 boxes, in the first branch, the box used is number 3)
now I have to find a way to translate this into code and add up the occurrences.

presents.gh (13.6 KB)

1 Like

I think I’ve solved the last part as well. luckily there was a similar situation in the old forum
the logic looks sound, now I need to check it for any mistakes.
Not a lot of help guys! (that’s what you get for posting on Sunday night hehehe)

presents.gh (20.7 KB)

1 Like