Skip to main content
Commonmark migration
Source Link

#Mathematica, 29 chars {s}//.l_List:>(l⋃##&@@(l/.G))

Mathematica, 29 chars

###Example: G = {1 -> {2, 3}, 2 -> {3}, 3 -> {1}, 4 -> {2}}; s = 1; {s}//.l_List:>(l⋃##&@@(l/.G))

{s}//.l_List:>(l⋃##&@@(l/.G))

Example:

G = {1 -> {2, 3}, 2 -> {3}, 3 -> {1}, 4 -> {2}}; s = 1;
{s}//.l_List:>(l⋃##&@@(l/.G))

{1, 2, 3}

#Mathematica, 29 chars {s}//.l_List:>(l⋃##&@@(l/.G))

###Example: G = {1 -> {2, 3}, 2 -> {3}, 3 -> {1}, 4 -> {2}}; s = 1; {s}//.l_List:>(l⋃##&@@(l/.G))

{1, 2, 3}

Mathematica, 29 chars

{s}//.l_List:>(l⋃##&@@(l/.G))

Example:

G = {1 -> {2, 3}, 2 -> {3}, 3 -> {1}, 4 -> {2}}; s = 1;
{s}//.l_List:>(l⋃##&@@(l/.G))

{1, 2, 3}

Post Undeleted by alephalpha
deleted 5 characters in body
Source Link
alephalpha
  • 50k
  • 7
  • 68
  • 182

#Mathematica, 29 chars Union@@{s}//.l_List:>(#l⋃##&@@(l/.G)&~FixedPoint~{s})

###Example: G = {1 -> {2, 3}, 2 -> {3}, 3 -> {1}, 4 -> {2}}; s = 1; Union @@ {s}//.l_List:>(# l⋃##&@@(l/. GG) &~FixedPoint~{s})

{1, 2, 3}

#Mathematica, 29 chars Union@@(#/.G)&~FixedPoint~{s}

###Example: G = {1 -> {2, 3}, 2 -> {3}, 3 -> {1}, 4 -> {2}}; s = 1; Union @@ (# /. G) &~FixedPoint~{s}

{1, 2, 3}

#Mathematica, 29 chars {s}//.l_List:>(l⋃##&@@(l/.G))

###Example: G = {1 -> {2, 3}, 2 -> {3}, 3 -> {1}, 4 -> {2}}; s = 1; {s}//.l_List:>(l⋃##&@@(l/.G))

{1, 2, 3}

Post Deleted by alephalpha
Source Link
alephalpha
  • 50k
  • 7
  • 68
  • 182

#Mathematica, 29 chars Union@@(#/.G)&~FixedPoint~{s}

###Example: G = {1 -> {2, 3}, 2 -> {3}, 3 -> {1}, 4 -> {2}}; s = 1; Union @@ (# /. G) &~FixedPoint~{s}

{1, 2, 3}