Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|cite|improve this question
For clarity: so $n$ is a length, not the area of the rectangle and you want a solution to the discrete problem (ie everything has integer length and can only be placed at integer positions not at 2.54234...)? – example Apr 3 '12 at 13:54
Yes, exactly right. Edited the original post for clarity. – WhatsInAName Apr 3 '12 at 13:57
What do you mean by a hole of length 4 and sub- rectangle of length 2, there are 3 ways? – Long Mai Apr 3 '12 at 14:08
Say the hole looks like this: oooo. The rectangle of length 2 looks like this: RR. There are three ways to arrange: RRoo, oRRo, ooRR – WhatsInAName Apr 3 '12 at 14:09
up vote 1 down vote accepted

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.

share|cite|improve this answer
This is very informative, and even has combinatoric info listed. I'll count this as an answer. Thank you! – WhatsInAName Apr 3 '12 at 14:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.