46.7 Arrangements

Arrangements( mset )
Arrangements( mset, k )

NrArrangements( mset )
NrArrangements( mset, k )

In the first form Arrangements returns the set of arrangements of the multiset mset. In the second form Arrangements returns the set of all arrangements with k elements of the multiset mset.

In the first form NrArrangements returns the number of arrangements of the multiset mset. In the second form NrArrangements returns the number of arrangements with k elements of the multiset mset.

An arrangement of mset is an ordered selection without repetitions and is represented by a list that contains only elements from mset, but maybe in a different order. If mset is a proper set there are |mset|! / (|mset|-k)! (see Factorial) arrangements with k elements.

As an example of arrangements of a multiset, think of the game Scrabble. Suppose you have the six characters of the word settle and you have to make a four letter word. Then the possibilities are given by

    gap> Arrangements( ["s","e","t","t","l","e"], 4 );
    [ [ "e", "e", "l", "s" ], [ "e", "e", "l", "t" ],
      [ "e", "e", "s", "l" ], [ "e", "e", "s", "t" ],
      # 96 more possibilities
      [ "t", "t", "s", "e" ], [ "t", "t", "s", "l" ] ] 

Can you find the five proper English words, where lets does not count? Note that the fact that the list returned by Arrangements is a proper set means in this example that the possibilities are listed in the same order as they appear in the dictionary.

    gap> NrArrangements( ["s","e","t","t","l","e"] );
    523 

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

Previous Up Top Next
Index

GAP 3.4.4
April 1997