i know this question might look like a duplicate. but i had a hard time trying to solve this and i couldn't find a helpful solution for my case
i'am implementing a genetic algorithm using python for the traveling salesman problem
assume we have those lists ( tours)
a = [1,0,2,5,4,3,1]
b = [1,2,5,4,3,0,1]
c = [1,3,5,4,2,0,1]
as you can see, the [5,4] is repeated in the whole 3 lists and a regular intersection would return all the elements in the list.
i want some function like intersect_list(a,b)
that returns [5,4]
is there a python built-in way to find this? or do you have any suggestion?.
Note : i know i can loop it to solve this , but please put in mind that in my case i have around 400 lists. and at the length of 401 each.
in other words : i want to see the common path between those lists.
please let me know if anything was unclear thanks in advance.