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

We have a 2D grid with n rows and m columns, we can fill it with numbers between 1 and k (both inclusive). Only condition is that for each r such that 1<=r<=k ,no two rows must have exactly the same number of the number r. We have to find the number of ways in which we can fill the grid .

share|cite|improve this question

Well, if no two rows can have the same number, you would be able to have a maximum of $k$ columns, since once you use the numbers from $1$ to $k$ in a row, you can't go any farther.

I think besides that there are no restrictions, so for a maximum size board you would have $nk!$ ways to do it.

If you mean that you can't have any numbers repeating in a row or column, then it would be a totally different story.

share|cite|improve this answer
You didnt get the question right, a row may have repeated numbers but no two rows must have same count of every number between 1 to k – user103260 Jan 31 '14 at 14:02

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.