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

I have a range of possible page design layouts consisting of rows and columns in those rows. There are a maximum of 6 possible rows, and a maximum of 5 possible columns per row.

How many unique permutations of rows and columns are there, presuming that the columns are always equally spaced, so that there are only 5 column options per row?

Here are two examples of permutations:

Row 1: 4 columns
Row 2: 3 columns
Row 3: 5 columns

Row 1: 1 column
Row 2: 2 columns
Row 3: 2 columns
Row 4: 2 columns
Row 5: 2 columns
Row 6: 2 columns

What would be doubly helpful would be pseudocode for printing out all the variations! Thanks!

share|cite|improve this question
up vote 1 down vote accepted

I'm unsure what you mean by "the columns are always equally spaced".

If each row can have any number of columns, up to five, then perhaps the simplest thing to do is to find the number of layouts for a specific number of rows; then sum these quantities.

If there are $i$ rows, then there are $5^i$ different layouts.

For example, if there are two rows, then there are 5 choices for the number of columns in row 1 and 5 choices for the number of columns in row two; so there are $5^2$ layouts when you have two rows.

So, the total number of layouts is $$ 5 + 5^2+ 5^3+ 5^4+ 5^5+ 5^6. $$

share|cite|improve this answer
Thank you David. My comment about the columns being equally spaced just confused the issue - you answered the question as it was intended. – Lemmy Jan 25 '12 at 17:00

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.