Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
6 added 292 characters in body
source | link

Wolfram Language 64 53 bytes

""<>#&/@#&/@Select[#~Subsets~{2},IntersectingQ@@#&]&

Finds all the input list's Subsets of length 2, Select those in which the nodes of one pair intersect with the nodes of another pair (indicating that the pairs share a node), and StringJoin the nodes for all selected pairs.

The code is especially difficult to read because it employs 4 nested pure (aka "anonymous") functions.

The code uses braces, "{}", as list delimiters, as is customary in Wolfram Language.

1 byte saved thanks to Mr. Xcoder.


Example

""<>#&/@#&/@Select[#~Subsets~{2},IntersectingQ@@#&]&[{{"1","2"},{"1","3"},{"1","4"},{"2","5"},{"3","4"},{"4","5"}}]

(*{{"12", "13"}, {"12", "14"}, {"12", "25"}, {"13", "14"}, {"13", "34"}, {"14", "34"}, {"14", "45"}, {"25", "45"}, {"34", "45"}}*)

Wolfram Language 64 53 bytes

""<>#&/@#&/@Select[#~Subsets~{2},IntersectingQ@@#&]&

Finds all the input list's Subsets of length 2, Select those in which the nodes of one pair intersect with the nodes of another pair (indicating that the pairs share a node), and StringJoin the nodes for all selected pairs.

The code is especially difficult to read because it employs 4 nested pure (aka "anonymous") functions.

The code uses braces, "{}", as list delimiters, as is customary in Wolfram Language.

1 byte saved thanks to Mr. Xcoder.

Wolfram Language 64 53 bytes

""<>#&/@#&/@Select[#~Subsets~{2},IntersectingQ@@#&]&

Finds all the input list's Subsets of length 2, Select those in which the nodes of one pair intersect with the nodes of another pair (indicating that the pairs share a node), and StringJoin the nodes for all selected pairs.

The code is especially difficult to read because it employs 4 nested pure (aka "anonymous") functions.

The code uses braces, "{}", as list delimiters, as is customary in Wolfram Language.

1 byte saved thanks to Mr. Xcoder.


Example

""<>#&/@#&/@Select[#~Subsets~{2},IntersectingQ@@#&]&[{{"1","2"},{"1","3"},{"1","4"},{"2","5"},{"3","4"},{"4","5"}}]

(*{{"12", "13"}, {"12", "14"}, {"12", "25"}, {"13", "14"}, {"13", "34"}, {"14", "34"}, {"14", "45"}, {"25", "45"}, {"34", "45"}}*)
5 added 110 characters in body
source | link

Wolfram Language 64 53 bytes

""<>#&/@#&/@Select[#~Subsets~{2},IntersectingQ@@#&]&

This findsFinds all the input list's Subset'ss of length 2, Select's those in which the nodes of one pair intersect with the nodes of another pair (indicating that the pairs share a node), and StringJoin's the nodes for all selected pairs.

The code is especially difficult to read because it employs 4 nested pure (aka "anonymous") functions.

The code uses braces, "{}", as list delimiters, as is customary in Wolfram Language.

""<>#&/@#&/@Select[#~Subsets~{2},IntersectingQ@@#&]&

1 byte saved thanks to Mr. Xcoder.

Wolfram Language 64 53 bytes

This finds all the Subset's of length 2, Select's those in which the nodes of one pair intersect with the nodes of another pair (indicating that the pairs share a node), and StringJoin's the nodes for selected pairs.

The code employs braces, "{}", as list delimiters, as is customary in Wolfram Language.

""<>#&/@#&/@Select[#~Subsets~{2},IntersectingQ@@#&]&

1 byte saved thanks to Mr. Xcoder.

Wolfram Language 64 53 bytes

""<>#&/@#&/@Select[#~Subsets~{2},IntersectingQ@@#&]&

Finds all the input list's Subsets of length 2, Select those in which the nodes of one pair intersect with the nodes of another pair (indicating that the pairs share a node), and StringJoin the nodes for all selected pairs.

The code is especially difficult to read because it employs 4 nested pure (aka "anonymous") functions.

The code uses braces, "{}", as list delimiters, as is customary in Wolfram Language.

1 byte saved thanks to Mr. Xcoder.

4 added 78 characters in body
source | link

Wolfram Language 6464 53 bytes

1 byte saved thanks to MrThis finds all the Subset's of length 2, Select's those in which the nodes of one pair intersect with the nodes of another pair (indicating that the pairs share a node), and StringJoin's the nodes for selected pairs. Xcoder

ThisThe code employs braces, "{}", as list delimiters, as is customary in Wolfram Language.

Select[#~Subsets~{2},IntersectingQ@@#&]""<>#&/.@#&/@Select[#~Subsets~{a_,b_2}:>{""<>a,""<>b}&IntersectingQ@@#&]&

It may be possible1 byte saved thanks to save some bytes by using Cases instead of Select but I have not yet found a wayMr. Xcoder.

Wolfram Language 64 bytes

1 byte saved thanks to Mr. Xcoder

This employs braces, "{}", as list delimiters, as is customary in Wolfram Language.

Select[#~Subsets~{2},IntersectingQ@@#&]/.{a_,b_}:>{""<>a,""<>b}&

It may be possible to save some bytes by using Cases instead of Select but I have not yet found a way.

Wolfram Language 64 53 bytes

This finds all the Subset's of length 2, Select's those in which the nodes of one pair intersect with the nodes of another pair (indicating that the pairs share a node), and StringJoin's the nodes for selected pairs.

The code employs braces, "{}", as list delimiters, as is customary in Wolfram Language.

""<>#&/@#&/@Select[#~Subsets~{2},IntersectingQ@@#&]&

1 byte saved thanks to Mr. Xcoder.

3 added 36 characters in body
source | link
2 added 110 characters in body
source | link
1
source | link