Machine Learning: Single input to variable number of outputs Is there a machine learning algorithm that maps a single input to an output list of variable length? If so, are there any implementations of the algorithm for public use? If not, what do you recommend as a workaround?

In my case, the input is a single scalar and the output is a list of scalars with variable length. For example, suppose I wanted to output a list of ones given the length of the list as input. Then &lt;input, output&gt; could be &lt;1, &#91;1&#93;>, &lt;2, [1, 1]>, etc. A small tweak would be providing the square root of the length in which case &lt;2, [1, 1, 1, 1]> would be an answer. Note: the input need not be tied directly to the output.

For a more complex example, suppose I want to learn the look-and-say sequence. Valid &lt;input, output&gt; pairs would be: &lt;1, &#91;1&#93;>, &lt;2, [1, 1]>, &lt;3, [2, 1]>, &lt;4, [1, 2, 1, 1]>, &lt;5, [1, 1, 1, 2, 2, 1]>, etc. My problem is also similar in that I can generate more examples; I am not restricted to a finite set of examples.
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.