KPermutations
The -permutations of : ordered selections of distinct elements, same family as Arrangements.
✓ checked against that system · ! checked, with disagreements (hover a chip)OEIS
A008279✓KPermutations(n, k)the ordered -element selections from Typed signatures
| Type | Package | Applies |
|---|---|---|
(integer<0..>, integer<0..>) -> indexed_collection<list<integer>> | combinatorics | always |
Definition
Epsil, as the implementation runs it.
count(_n, _k)
Fold(Function(product * f, product, f), 1, Range(_n - _k + 1, _n, 1)) if _k <=
_n else 0unrank(_n, _k, _r)
Map(Function(Fold(
Function(v + 1 if v >= (_r - _r % Fold(
Function(
product * f,
product,
f,
),
1,
Range(
_n - i - (_k -
i) +
1,
_n - i,
1,
),
)) / Fold(
Function(
product *
f,
product,
f,
),
1,
Range(
_n - i -
(_k -
i) + 1,
_n - i,
1,
),
) % (_n - i + 1) +
1 else v, v, i),
(_r - _r % Fold(
Function(product * f, product, f),
1,
Range(_n - j - (_k - j) + 1, _n - j, 1),
)) / Fold(
Function(product * f, product, f),
1,
Range(
_n - j - (_k - j) + 1,
_n - j,
1,
),
) % (_n - j + 1) + 1,
Range(j - 1, 1, -1),
), j), Range(1, _k, 1))rank(_n, _k, _x)
Fold(
Function(
r * (_n - j + 1) + (_x[j] - 1 - Fold(
Function(c +
(1 if _x[i] <
_x[j] else 0), c, i),
0,
Range(1, j - 1, 1),
)),
r,
j,
),
0,
Range(1, _k, 1),
)valid(_n, _k, _x)
Fold(Function(
(ReplaceAt(di_seen, _x[di_j], 1) if di_seen[_x[di_j]] == 0 else ReplaceAt(
di_seen,
_n + 1,
1,
)) if 1 <= _x[di_j] &&
_x[di_j] <= _n else ReplaceAt(di_seen, _n + 1, 1),
di_seen,
di_j,
), Map(Function(0, di_z), Range(1, _n + 1, 1)), Range(1, _k, 1))[_n +
1] ==
0 if Length(_x) == _k else FalseExamples
About
| Examples | 2 |
|---|---|
| Crosswalk | OEIS |
See also: Arrangements