Low-level splits

sage.combinat.split_nk.SplitNK(n, k)

Returns the combinatorial class of splits of a the set range(n) into a set of size k and a set of size n-k.

EXAMPLES:

sage: from sage.combinat.split_nk import SplitNK
sage: S = SplitNK(5,2); S
Splits of {0, ..., 4} into a set of size 2 and one of size 3
sage: S.first()
[[0, 1], [2, 3, 4]]
sage: S.last()
[[3, 4], [0, 1, 2]]
sage: S.list()
[[[0, 1], [2, 3, 4]],
 [[0, 2], [1, 3, 4]],
 [[0, 3], [1, 2, 4]],
 [[0, 4], [1, 2, 3]],
 [[1, 2], [0, 3, 4]],
 [[1, 3], [0, 2, 4]],
 [[1, 4], [0, 2, 3]],
 [[2, 3], [0, 1, 4]],
 [[2, 4], [0, 1, 3]],
 [[3, 4], [0, 1, 2]]]
class sage.combinat.split_nk.SplitNK_nk(n, k)

Bases: sage.combinat.combinat.CombinatorialClass

TESTS:

sage: from sage.combinat.split_nk import SplitNK
sage: S = SplitNK(5,2)
sage: S == loads(dumps(S))
True
cardinality()

Returns the number of choices of set partitions of range(n) into a set of size k and a set of size n-k.

EXAMPLES:

sage: from sage.combinat.split_nk import SplitNK
sage: SplitNK(5,2).cardinality()
10
random_element()

Returns a random set partition of range(n) into a set of size k and a set of size n-k.

EXAMPLES:

sage: from sage.combinat.split_nk import SplitNK
sage: SplitNK(5,2).random_element()
[[0, 2], [1, 3, 4]]

Previous topic

Low-level permutations

Next topic

Low-level Combinations

This Page