Problem 628. Book Club
A book club that has K members, as a group, have to read N books. Return how many different ways the members could read the books. All of the books must be read by at least one member of the group and all of the members must read one and only one book.
For Example, for K = 3 and N = 2, there are 6 ways
- Member 1 reads book 1, Member 2 reads book 1, Member 3 reads book 2
- Member 1 reads book 1, Member 2 reads book 2, Member 3 reads book 1
- Member 1 reads book 1, Member 2 reads book 2, Member 3 reads book 2
- Member 1 reads book 2, Member 2 reads book 1, Member 3 reads book 1
- Member 1 reads book 2, Member 2 reads book 1, Member 3 reads book 2
- Member 1 reads book 2, Member 2 reads book 2, Member 3 reads book 1
Note: all of the test cases use small values of n and k to allow for brute-force solutions.
Solution Stats
Problem Comments
-
4 Comments
Same for me... i'm not sure if I understand the problem correctly... If my combinatorics is right, the solution should simply be factorial(k)/factorial(k-n) but apparently this is not the case... I assume I'm misinterpreting something???
sorry if i wasn't clear enough. i'm revising my question to be more specific now
Mathematical Reformulation: How many K-letter words can be formed using N-letters if repetition of letters is allowed and each letter appears at least once?....Hint: A closed form solution exist aside the brute force solutions.
Solution Comments
Show commentsProblem Recent Solvers18
Suggested Problems
-
Determine whether a vector is monotonically increasing
21344 Solvers
-
Check to see if a Sudoku Puzzle is Solved
328 Solvers
-
344 Solvers
-
229 Solvers
-
Find third Side of a right triangle given hypotenuse and a side. No * - or other functions allowed
245 Solvers
More from this Author56
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!