Let's say I have a list of lists of every possible transfer between two bus lines.
[a,b]
[b,a]
[b,c]
[c,b]
[b,e]
[e,b]
[c,e]
[e,c]
I want to go from a -> e
Wanted results:
[a,b,c,e]
[a,b,e]
You can read the above as:
[a,b]
[b,e]
a -> b -> e = [a,b,e]
If I went c->b, i can't go back (b->c)
What's the easiest way to get those lists of transfers?