Skip to main content
added 135 characters in body
Source Link
ben
  • 107
  • 4

Could this work for your problem?

A = {a, b, c, d, e, f, g} list = Union[Flatten[Map[Partition[#, 2] &, Permutations[A]], 1]] Extract[list, RandomInteger[{1, Length[list]}]] 

Change the predicate in the Partition function for different lengths.

f[_] := Extract[list, RandomInteger[{1, Length[list]}]] Array[f, 10] 

will generate 10 subsets for (pseudo)random pairs.

Could this work for your problem?

A = {a, b, c, d, e, f, g} list = Union[Flatten[Map[Partition[#, 2] &, Permutations[A]], 1]] Extract[list, RandomInteger[{1, Length[list]}]] 

Change the predicate in the Partition function for different lengths.

Could this work for your problem?

A = {a, b, c, d, e, f, g} list = Union[Flatten[Map[Partition[#, 2] &, Permutations[A]], 1]] Extract[list, RandomInteger[{1, Length[list]}]] 

Change the predicate in the Partition function for different lengths.

f[_] := Extract[list, RandomInteger[{1, Length[list]}]] Array[f, 10] 

will generate 10 subsets for (pseudo)random pairs.

Source Link
ben
  • 107
  • 4

Could this work for your problem?

A = {a, b, c, d, e, f, g} list = Union[Flatten[Map[Partition[#, 2] &, Permutations[A]], 1]] Extract[list, RandomInteger[{1, Length[list]}]] 

Change the predicate in the Partition function for different lengths.