Machine Learning: Single input to variable number of outputs
I would try to set a multilabel classification algorithm and make the output standard by adding zeros. So if your data is like this: &lt;1, 1>, &lt;2, [1, 1]>, &lt;3, [2, 1]>, &lt;4, [1, 2, 1, 1]>, &lt;5, [1, 1, 1, 2, 2, 1]>. The maximum number of output is 6. So you could transform your data into something like: 
&lt;1, [1,0,0,0,0,0]>, &lt;2, [1, 1,0,0,0,0]>, &lt;3, [2, 1,0,0,0,0]>, &lt;4, [1, 2, 1, 1,0,0]>, &lt;5, [1, 1, 1, 2, 2, 1]>

Another option that occurs to me is to add the limit dynamically. Let say you have your training and test set. You can search for the biggest length and create an algorithm that adds the zeros to both datasets. Then let's say a new data you want to predict has a bigger length, then you'll need to recompute all training and test with for this new prediction. You can even check how extending the limit affects your model.