Put m balls into n boxes - MATLAB Cody - MATLAB Central

Problem 1516. Put m balls into n boxes

Difficulty:Rate
Can you find all the cases where, if I put 3 balls into 2 boxes
the case is
1 1 1
1 1 2
1 2 2
2 2 2
the columns stand for a ball, the number stands for box, and the row stands for a case.
So we have 4 cases
You should write a function, input m and n, m stand for the number of balls, n stands for the number of boxes, output all the cases.
Example
If m = 3, n = 4 then you should output
1 1 1
1 1 2
1 1 3
1 1 4
1 2 2
1 2 3
1 2 4
1 3 3
1 3 4
1 4 4
2 2 2
2 2 3
2 2 4
2 3 3
2 3 4
2 4 4
3 3 3
3 3 4
3 4 4
4 4 4

Solution Stats

43.02% Correct | 56.98% Incorrect
Last Solution submitted on Jun 08, 2024

Problem Comments

Solution Comments

Show comments
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Problem Recent Solvers66

Suggested Problems

More from this Author17

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page