+ 3
How to build lists where there are y items in the list, and the sum of the items are x?
Say the user input is 3 and 4. I'm trying to write a code that will (in this example) give me three lists with 4 items each, where the sum of the items of any given list equals three. So in this case, I would get [3,0,0,0] [2,1,0,0] [1,1,1,0] BTW, These lists will evenutually get permutated. Would it be easier to direclty generate all of the permutations at once instead of making one permutation and then permuting it? Ex [3,0,0,0] [0,3,0,0] [0,0,3,0] etc. (And do the same with the other lists)
1 Respuesta
+ 3
You could try a two-dimensional array list with linear sorting if your adding more info.