I’d like an help on this algorithm.
I have a text file like this:
input1
input2
etc...
Every inputX has a subset of elements, like:
input1 -> {input1_1, input1_2, ...}
input2 -> {input2_1, input2_2, input_2_3, ...}
inputX -> {inputX_1, inputX_2, inputX_3, ...}
I have to produce something similar at:
input1_1
input2_1
--------
input1_2
input2_1
--------
input1_1
input2_2
--------
input1_2
input2_2
--------
input1_1
input2_3
--------
input1_2
input2_3
--------
Can you suggest some algorithms to me?
All I can think about it’s a while/for loop, but I don’t know how to properly set it.
Thank you very much,
Pierpaolo
If you know how many lists there are, you can do it with nested loops:
If you do not know how many lists there are, you need a recursive solution: