List logic to combine and filter lists


#1


I want to combine items from matching list indices to sub lists as shown in the middle code block and later make sub lists again if they include a common item ( list 0 is combined with list 2 as “a” is common to both).
Is it possible to do this?


#2

It is possible.


#3

Thanks @Tomasz. Some great logic you got there.