I want to know how to print all possible arrays of given length N having sum equal to given number S.
(this is sub-problem of a problem, so i didnt share exact question)
Example
if, N=4 S=5
My output should be
[5 0 0 0]
[4 1 0 0]
[4 0 1 0]
[4 0 0 1]
[3 2 0 0]
[3 1 1 0]
[3 1 0 1]
[3 0 2 0]
[3 0 1 1]
[3 0 0 2]
[2 3 0 0]
…(more lines are there)
here sum of every line is equal to 5(K) having length 4(N)
please help me to do same.
thank you