I already asked the question on StackOverflow, but I thoughted more about the problem, and my question is now not about programming but graph theory.
I would like to combine several lists, the result must be a list of unique elements formed by concatenating permutations of the initial lists.
Here is an example:
I would like to combine these lists
[[0, 7], [2, 4], [0, 1, 7], [0, 1, 4, 7]]
The output I would like to obtain is e.g. this list
[2, 4, 0, 7, 1]
Putting each unique element from all initial lists as nodes in a graph (e.g. 0, 1, 2, 4, and 7) and weighting the edges between two nodes with the number of occurrences of any permutation of these two nodes, I obtain a graph like this for this example
My hypothesis now is, that the maximum weighted hamiltonian path is the solution (result list). For the examples I did, it was correct - but now I am searching for proof. I am not a mathematician/ computer scientist, I have no clue how to start to find such proof.