Low-level permutations

class sage.combinat.permutation_nk.PermutationsNK(n, k)
__init__(n, k)

TESTS:

sage: from sage.combinat.permutation_nk import PermutationsNK
sage: a = PermutationsNK(3,2)
sage: a == loads(dumps(a))
True
__iter__()

An iterator for all permutations of k things from range(n).

EXAMPLES:

sage: from sage.combinat.permutation_nk import PermutationsNK
sage: [ p for p in PermutationsNK(3,2)]
[[0, 1], [0, 2], [1, 0], [1, 2], [2, 0], [2, 1]]
sage: len(PermutationsNK(5,4).list())
120
sage: [1, 2, 2, 0] in PermutationsNK(5,4).list()
False
cardinality()

Returns the number of permutations of k things from a list of n things.

EXAMPLES:

sage: from sage.combinat.permutation_nk import PermutationsNK
sage: PermutationsNK(3,2).cardinality()
6
sage: PermutationsNK(5,4).cardinality()
120
random_element()

Returns a random permutation of k things from range(n).

EXAMPLES:

sage: from sage.combinat.permutation_nk import PermutationsNK
sage: PermutationsNK(3,2).random_element()
[0, 1]

Previous topic

Output functions

Next topic

Low-level splits

This Page