Asking this question on SO, I have been advised to post it here. I will be using Javascript to implement :
Please consider a row of size 12. On that row, I want to place some items that have 3 different width : 1, 2 and 3.
I would like to get all the possible combination of items on that row such that the sum of their width is equal to the row size.
For example, I could have :
[1,1,1,1,1,1,1,1,1,1,1,1] (12 items of size 1)
[2,2,2,2,2,2] (6 items of size 2)
[3,3,3,3] (4 items of size 3)
[3,3,3,1,1,1] (3 items of size 3 + 3 items of size 1)
[2,2,1,1,3,3] (2 items of size 2 + 2 items of size 1 + 2 items of size 3)