MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

According to Cody Problem 1516, if I put 3 balls into 2 boxes then

1 1 1 1 1 2 1 2 2 2 2 2

The columns stand for a ball, the number stands for a box, and the row stands for a case.

**Now we count the number of balls in each boxes.**

so we get

3 0 2 1 1 2 0 3

the 1-th row stand for the 1-th case,3 balls are put into the first boxes,the others is empty the 2-th row stand for the 2-th case,2 balls are put into the first boxes,1 balls is put into the second boxes

You should write a function, input m and n, m stand for the number of balls ,n stand for the number of boxes,output all the cases.

Example

If m = 3,n = 4, you should output

3 0 0 0 2 1 0 0 2 0 1 0 2 0 0 1 1 2 0 0 1 1 1 0 1 1 0 1 1 0 2 0 1 0 1 1 1 0 0 2 0 3 0 0 0 2 1 0 0 2 0 1 0 1 2 0 0 1 1 1 0 1 0 2 0 0 3 0 0 0 2 1 0 0 1 2 0 0 0 3

15 correct solutions
11 incorrect solutions

Last solution submitted on Aug 03, 2014