I have a list of lists(of lists):
{{{1}, {2}, {1, 2, 3}}, {{1}, {3}, {1, 2, 3}}, {{1}, {1, 2}, {1,2,
3}}, {{1}, {2, 3}, {1, 2, 3}}, {{2}, {3}, {1, 2, 3}}, {{2}, {1,
2}, {1, 2, 3}}, {{2}, {2, 3}, {1, 2, 3}}, {{3}, {1, 2}, {1, 2,
3}}, {{3}, {2, 3}, {1, 2, 3}}, {{1, 2}, {2, 3}, {1, 2, 3}}}
From the list above I want to select those lists in which two consecutive elements share either a first element or last element. It also counts if the first element of the list shares the first entry with the second element of that list, but the second element shares the last entry with the third element, etc. So from the list above I would get:
{{1},{1,2},{1,2,3}},{{2},{1,2},{1,2,3}},{{2},{2,3},{1,2,3}},{{3},{2,3},{1,2,3}}
So I did the following:test4 = Table[Select[test3,First[#[[i+1]]]==First[#[[i]]] \[Or] Last[#[[i+1]]]==Last[#[[i]]] &],{i,n-1}]
where test3 is my list of lists from above and n is the maximum length that the element in one of the list of lists can have, so in our case it is 3 and that number is known in advance. Unforunately the above doesn't work. It spits out more elements then there are in the initial list. I think it picks the elements which satify that condition for at least one pair of consecutive elements, which is not what I'm after. I'd really appreciate some help with this. Thanks!