I've been searching around, but I'm not quite sure how to word this. I have a list of lists, and each inner list is a certain size, k. I want to generate a list of combinations that have the size k+1. So for instance, if I start with:
[[1,2],[1,3],[3,4]]
I want to generate the list:
[[1,2,3],[1,3,4]]
Where the lists are arbitrarily long. I'm thinking I'll need to use the combinations function from the itertools library, and possibly sets with unions. I'm just kind of stuck as to how to go about this efficiently.
Any help is greatly appreciated!
Edit: I need to clarify. I'm only trying to generate the lists of length k+1 (3 in this case) where two of the original lists are combined. So if they were sets, I want only the resulting sets of length k+1 when we take the union of two sets.