algorithm to combinatorics
- by peiska
I am trying to solve a combinatorics problem, it seems easy, but i am having some trouble with it.
If i have at most X tables, and N persons to sit on the tables, Each table can have 1 to N seating places, and I can only sit persons in one side of a rectangular table( so the order how people sit matters).
I want to make a code that can calculate all the distributions of seating places from 1 up to K tables.
For example, if I have 12 persons and 1 table i have 479001600 ways of seating persons( thats easy to calculate I've used Factorial of 12).
But if I have 12 persons and 3 tables i have 4390848000 ways of seating persons. I've tried different solutions but i was not able to find the correct one.
I've tried to divided the 12 in 3, then o use factorial of the result (it didnt work), i've tried to use 12! * 3( it didn't work too).
Can some one give me a tip in a algorithm that i can use?