46.8 UnorderedTuples

UnorderedTuples( set, k )

NrUnorderedTuples( set, k )

UnorderedTuples returns the set of all unordered tuples of length k of the set set.

NrUnorderedTuples returns the number of unordered tuples of length k of the set set.

An unordered tuple of length k of set is a unordered selection with repetitions of set and is represented by a sorted list of length k containing elements from set. There are {|set|+k-1 choose k} (see Binomial) such unordered tuples.

Note that the fact that UnOrderedTuples returns a set implies that the last index runs fastest. That means the first tuple contains the smallest element from set k times, the second tuple contains the smallest element of set at all positions except at the last positions, where it contains the second smallest element from set and so on.

As an example for unordered tuples think of a poker-like game played with 5 dice. Then each possible hand corresponds to an unordered five-tuple from the set [1..6]

    gap> NrUnorderedTuples( [1..6], 5 );
    252
    gap> UnorderedTuples( [1..6], 5 );
    [ [ 1, 1, 1, 1, 1 ], [ 1, 1, 1, 1, 2 ], [ 1, 1, 1, 1, 3 ],
      [ 1, 1, 1, 1, 4 ], [ 1, 1, 1, 1, 5 ], [ 1, 1, 1, 1, 6 ],
      # 99 more tuples
      [ 1, 3, 4, 5, 6 ], [ 1, 3, 4, 6, 6 ], [ 1, 3, 5, 5, 5 ],
      # 99 more tuples
      [ 3, 3, 4, 4, 5 ], [ 3, 3, 4, 4, 6 ], [ 3, 3, 4, 5, 5 ],
      # 39 more tuples
      [ 5, 5, 6, 6, 6 ], [ 5, 6, 6, 6, 6 ], [ 6, 6, 6, 6, 6 ] ] 

The function Combinations (see Combinations) computes unordered selections without repetitions, Arrangements (see Arrangements) computes ordered selections without repetitions and Tuples (see Tuples) computes ordered selections with repetitions.

Previous Up Top Next
Index

GAP 3.4.4
April 1997