0

I have a list of lists of the following form :

[[1,2],[2,4],[2,5],[3,5],[4,5],[5,6]]

the trio in the list would be :

[2,4,5]

formed from the lists : [2,4], [2,5], [4,5]

I'm really stuck at this for a long time. Any help would be appreciated.

I have tried implementing a dictionary for the same, but wasn't able to proceed after that.

friend_pairs = [[a,b] for a,b in zip(friends_from, friends_to)] #input list
dic = {}
print(friend_pairs)
for a,b in friend_pairs:
    if a in dic:
        dic[a].append(b)
    else:
         dic[a] = [b]
print(dic)

I would like to solve the problem without any external libraries such as networkz

Suraj
  • 2,253
  • 3
  • 17
  • 48

0 Answers0