[Math] Number of ways I can fit rectangles within a longer rectangle

combinatorics

Say I have a long rectangular hole of size n and then a bunch of smaller rectangles of different lengths a, b, c, etc such that the sum of their lengths is <=n.

I am trying to figure out the number of distinct permutations. For instance, if I had a hole of length 4 and two rectangles of length 2, there's only one way to arrange that. But if I had one of length 3 and one of length 1, that's two ways to arrange it.

If I had a hole of length 4 and a sub-rectangle of length 2, there are 3 ways, and so on.

Edit for clarification: The lengths are integers only, and they can only be "snapped" in at integer intervals (so you can't place a rectangle at, say, 1.233249 and then claim there are infinitely many ways to insert a rectangle). Area also doesn't matter… the height of the rectangles are all the same. It's only the lengths that differ.

Is there a simple mathematical combinatoric that can be applied here?

Best Answer

You are asking about partitions if the order doesn't matter, and compositions if it does. It sounds like 13 is different from 31, so compositions are what you are after.