Skip to content

PartitionsIntoKParts ​

The integer partitions of nn into exactly kk positive parts.

✓ checked against that system · ! checked, with disagreements (hover a chip)OEISA072233✓
PartitionsIntoKParts(n, k)partitions of nn with exactly kk parts
Typed signatures
TypePackageApplies
(integer<0..>, integer<0..>) -> indexed_collection<integer_partition>combinatoricsalways

Domain: Collections

Definition

Epsil, as the implementation runs it.

count(_n, _k)

_tables[_n * (Min(_k, _n + 1) + 1) * (_n + 1) +
        Min(_k, _n + 1) * (_n + 1) + _n + 1]

unrank(_n, _k, _r)

Drop(Fold(
           Function(Apply((pw_m: integer) => Apply((pw_c: integer) => Apply((pw_r: integer) => pw_u if pw_m == 0 else Apply(
                                                                                                                             (pw_chosen: list<integer>) => Join([
                                                                                                                                                                  pw_m - pw_chosen[2],
                                                                                                                                                                  ((pw_c -
                                                                                                                                                                    pw_c %
                                                                                                                                                                    (_n + 1)) /
                                                                                                                                                                   (_n + 1) -
                                                                                                                                                                   1) *
                                                                                                                                                                  (_n + 1) +
                                                                                                                                                                  pw_chosen[2],
                                                                                                                                                                  pw_chosen[1],
                                                                                                                                                                ], Drop(pw_u, 3), [pw_chosen[2]]),
                                                                                                                             Fold(
                                                                                                                                   Function(pw_pick if pw_pick[2] != 0 else Apply(
                                                                                                                                                                                   (pw_k: integer) => [pw_pick[1], pw_p] if pw_pick[1] < pw_k else [pw_pick[1] - pw_k, 0],
                                                                                                                                                                                   _tables[(pw_m - pw_p) *
                                                                                                                                                                                           (Min(_k, _n + 1) +
                                                                                                                                                                                            1) *
                                                                                                                                                                                           (_n + 1) +
                                                                                                                                                                                           ((pw_c -
                                                                                                                                                                                             pw_c %
                                                                                                                                                                                             (_n + 1)) /
                                                                                                                                                                                            (_n + 1) -
                                                                                                                                                                                            1) *
                                                                                                                                                                                           (_n + 1) +
                                                                                                                                                                                           pw_p +
                                                                                                                                                                                           1],
                                                                                                                                                                                 ) if (pw_c -
                                                                                                                                                                                      pw_c %
                                                                                                                                                                                      (_n + 1)) /
                                                                                                                                                                                     (_n + 1) >=
                                                                                                                                                                                     1 else pw_pick, pw_pick, pw_p),
                                                                                                                                   [pw_r, 0],
                                                                                                                                   Range(Min(pw_m, pw_c %
                                                                                                                                                   (_n + 1)), 1, -1),
                                                                                                                                 ),
                                                                                                                           ), pw_u[3]), pw_u[2]), pw_u[1]), pw_u, pw_i),
           [_n, Min(_k, _n + 1) * (_n + 1) + _n, _r],
           Range(1, _n, 1),
         ), 3)

rank(_n, _k, _x)

Fold(
      Function(Apply((pw_r: integer) => Apply((pw_m: integer) => Apply((pw_c: integer) => [
                                                                                            pw_r +
                                                                                            Fold(
                                                                                                  Function(pw_s +
                                                                                                           (_tables[(pw_m - pw_q) *
                                                                                                                    (Min(_k, _n + 1) +
                                                                                                                     1) *
                                                                                                                    (_n + 1) +
                                                                                                                    ((pw_c -
                                                                                                                      pw_c %
                                                                                                                      (_n + 1)) /
                                                                                                                     (_n + 1) -
                                                                                                                     1) *
                                                                                                                    (_n + 1) +
                                                                                                                    pw_q +
                                                                                                                    1] if (pw_c -
                                                                                                                          pw_c %
                                                                                                                          (_n + 1)) /
                                                                                                                         (_n + 1) >=
                                                                                                                         1 else 0), pw_s, pw_q),
                                                                                                  0,
                                                                                                  Range(
                                                                                                         pw_x + 1,
                                                                                                         Min(pw_m, pw_c %
                                                                                                                   (_n + 1)),
                                                                                                         1,
                                                                                                       ),
                                                                                                ),
                                                                                            pw_m - pw_x,
                                                                                            ((pw_c -
                                                                                              pw_c %
                                                                                              (_n + 1)) /
                                                                                             (_n + 1) -
                                                                                             1) *
                                                                                            (_n + 1) +
                                                                                            pw_x,
                                                                                          ], pw_a[3]), pw_a[2]), pw_a[1]), pw_a, pw_x),
      [0, _n, Min(_k, _n + 1) * (_n + 1) + _n],
      _x,
    )[1]

valid(_n, _k, _x)

Apply(
       (pw_end: list<integer>) => pw_end[1] == 1 && pw_end[2] == 0 && (1 if (pw_end[3] -
                                                                             pw_end[3] %
                                                                             (_n +
                                                                              1)) /
                                                                            (_n +
                                                                             1) ==
                                                                            0 else 0) !=
                                                                      0,
       Fold(Function(Apply(
                            (pw_f: integer) => Apply((pw_m: integer) => Apply((pw_c: integer) => [
                                                                                                   1,
                                                                                                   pw_m - pw_y,
                                                                                                   ((pw_c -
                                                                                                     pw_c %
                                                                                                     (_n + 1)) /
                                                                                                    (_n + 1) -
                                                                                                    1) *
                                                                                                   (_n + 1) +
                                                                                                   pw_y,
                                                                                                 ] if pw_f == 1 &&
                                                                                                     pw_y >= 1 &&
                                                                                                     pw_y <=
                                                                                                     Min(pw_m, pw_c %
                                                                                                               (_n + 1)) &&
                                                                                                     (pw_c -
                                                                                                      pw_c %
                                                                                                      (_n + 1)) /
                                                                                                     (_n + 1) >=
                                                                                                     1 else [0, 0, 0], pw_v[3]), pw_v[2]),
                            pw_v[1],
                          ), pw_v, pw_y), [
                                           1,
                                           _n,
                                           Min(_k, _n + 1) * (_n + 1) + _n,
                                         ], _x),
     )

tables(_n, _k)

Fold(
      Function(Join(
                     pw_t,
                     Fold(
                           Function(ReplaceAt(
                                               pw_row,
                                               pw_c + 1,
                                               Fold(
                                                     Function(pw_a +
                                                              (pw_t[(pw_s - pw_p) *
                                                                    (Min(_k, _n +
                                                                             1) +
                                                                     1) *
                                                                    (_n + 1) +
                                                                    ((pw_c - pw_c %
                                                                             (_n +
                                                                              1)) /
                                                                     (_n + 1) - 1) * (_n +
                                                                              1) +
                                                                    pw_p + 1] if (pw_c -
                                                                          pw_c %
                                                                          (_n +
                                                                           1)) / (_n +
                                                                               1) >=
                                                                         1 else 0), pw_a, pw_p),
                                                     0,
                                                     Range(1, Min(pw_s, pw_c %
                                                                        (_n + 1)), 1),
                                                   ),
                                             ), pw_row, pw_c),
                           Map(
                                Function(0, pw_z),
                                Range(
                                       0,
                                       (Min(_k, _n + 1) + 1) * (_n + 1) - 1,
                                       1,
                                     ),
                              ),
                           Range(0, (Min(_k, _n + 1) + 1) * (_n + 1) - 1, 1),
                         ),
                   ), pw_t, pw_s),
      Fold(
            Function(
                      ReplaceAt(pw_row, pw_c + 1, 1 if (pw_c - pw_c % (_n + 1)) /
                                                       (_n + 1) == 0 else 0),
                      pw_row,
                      pw_c,
                    ),
            Map(
                 Function(0, pw_z),
                 Range(0, (Min(_k, _n + 1) + 1) * (_n + 1) - 1, 1),
               ),
            Range(0, (Min(_k, _n + 1) + 1) * (_n + 1) - 1, 1),
          ),
      Range(1, _n + 1 - 1, 1),
    )

Statistics

On IntegerPartition, called as CombinatorialStat(x, "Name").

Maps

Into and out of IntegerPartition, called as CombinatorialMap(x, "Name"). Properties are the laws we state and what FindStat records.

From IntegerPartition

  • BinaryWordIntegerPartition → BinaryWordInjectionMp00095The shape's boundary read from the first row down: 1 for a step down, 0 for a step left.
  • BulgarianSolitaireIntegerPartition → IntegerPartitionGraded mapMp00308A move of Bulgarian solitaire: the first column of the Ferrers diagram becomes a new row.
  • GlaisherFranklinIntegerPartition → IntegerPartitionbijectioninverseBijectionGraded mapMp00312The Glaisher-Franklin bijection: even part sizes halved become repeated parts, and repeated odd parts merge into their binary multiples.
  • InitialTableauIntegerPartition → StandardTableauInjectionGraded mapMp00042The standard tableau of the shape filled row by row with 1, 2, ..., n.
  • InverseGlaisherFranklinIntegerPartition → IntegerPartitionbijectioninverseBijectionGraded mapMp00313The inverse of GlaisherFranklin: repeated parts merge into doubled parts, and a leftover part splits into copies of its odd part.
  • MinimalDyckPathIntegerPartition → DyckPathInjectionMp00043The shortest Dyck path tracing the shape of the Ferrers diagram.
  • OddPartsWordIntegerPartition → BinaryWordSurjectionMp00317The binary word marking which parts are odd, the parts taken largest first.
  • ParallelogramPolyominoDyckPathIntegerPartition → DyckPathInjectionMp00230The Dyck path of the partition read as a parallelogram polyomino, one column per part.
  • ReadingTableauIntegerPartition → StandardTableauInjectionGraded mapMp00045The recording tableau of the row reading word of the shape filled row by row.
  • RemoveFirstPartIntegerPartition → IntegerPartitionSurjectionMp00202The partition without its largest part: its first row removed.
  • TransposePartitionIntegerPartition → IntegerPartitioninvolutionBijectionGraded mapInvolutionMp00044The conjugate partition: column i of the Ferrers diagram becomes row i.

To IntegerPartition

  • BlockSizePartitionSetPartition → IntegerPartitionsurjectionSurjectionGraded mapMp00079The partition of n a set partition's block sizes form, largest first.
  • ConjugateAfterCycleTypePermutation → IntegerPartitionThe conjugate partition of the cycle type.
  • CutOutPartitionDyckPath → IntegerPartitionInjectionMp00027The partition cut out of the staircase by the path: part i is the number of downs before the (n + 1 - i)-th up step.
  • CycleTypePermutation → IntegerPartitionsurjectionSurjectionGraded mapMp00108The multiset of cycle lengths, as a partition.
  • NegativeCycleTypeSignedPermutation → IntegerPartitionSurjectionMp00169The lengths of the negative cycles, largest first: those of the underlying permutation with an odd number of negative entries.
  • PositiveCycleTypeSignedPermutation → IntegerPartitionSurjectionMp00166The lengths of the positive cycles, largest first: those of the underlying permutation with an even number of negative entries.
  • RskShapePermutation → IntegerPartitionsurjectionSurjectionGraded mapMp00060The common shape of the RSK tableaux: the row lengths, as a partition of n.
  • SortedPartitionIntegerComposition → IntegerPartitionsurjectionSurjectionGraded mapMp00040The partition a composition's parts form, sorted largest first.
  • TableauShapeStandardTableau → IntegerPartitionsurjectionSurjectionGraded mapMp00083The shape of a standard tableau: its row lengths.
21 more in FindStat, not implemented here
  • Mp00021CorePartition → IntegerPartitionGraded mapBijectionto bounded partition
  • Mp00022CorePartition → IntegerPartitionSurjectionto partition
  • Mp00037LabeledGraph → IntegerPartitionSurjectionGraded mapto partition of connected components
  • Mp00077SemistandardTableau → IntegerPartitionSurjectionGraded mapshape
  • Mp00110Posets → IntegerPartitionSurjectionGraded mapGreene-Kleitman invariant
  • Mp00179IntegerPartition → SkewPartitionInjectionGraded mapto skew partition
  • Mp00182SkewPartition → IntegerPartitionSurjectionouter shape
  • Mp00183SkewPartition → IntegerPartitionSurjectioninner shape
  • Mp00186SkewPartition → IntegerPartitionSurjectionGraded mapdominating partition
  • Mp00204Permutation → IntegerPartitionSurjectionGraded mapLLPS
  • Mp00225SemistandardTableau → IntegerPartitionSurjectionweight
  • Mp00251LabeledGraph → IntegerPartitionclique sizes
  • Mp00275LabeledGraph → IntegerPartitionSurjectionto edge-partition of connected components
  • Mp00276LabeledGraph → IntegerPartitionto edge-partition of biconnected components
  • Mp00306Posets → IntegerPartitionrowmotion cycle type
  • Mp00307Posets → IntegerPartitionpromotion cycle type
  • Mp00311PlanePartition → IntegerPartitionGraded mapto partition
  • Mp00321IntegerPartition → IntegerPartitionBijectionGraded mapInvolution2-conjugate
  • Mp00322IntegerPartition → IntegerPartitionBijectionGraded mapLoehr-Warrington
  • Mp00323IntegerPartition → IntegerPartitionBijectionGraded mapLoehr-Warrington inverse
  • Mp00332Posets → IntegerPartitionSurjectionGraded mapJordan block partition

Examples

Basic #

8=6+1+1=5+2+1=4+3+1=4+2+2=3+3+28 = 6+1+1 = 5+2+1 = 4+3+1 = 4+2+2 = 3+3+2

live ↗
InCount(PartitionsIntoKParts(8,3))\mathrm{Count}(\mathrm{PartitionsIntoKParts}(8, 3))Out55

Exactly 3 positive parts

live ↗
InTake(PartitionsIntoKParts(6,3),3)\mathrm{Take}(\mathrm{PartitionsIntoKParts}(6, 3), 3)Out[IntegerPartition⁡([4,1,1]),IntegerPartition⁡([3,2,1]),IntegerPartition⁡([2,2,2])]\bigl\lbrack{\operatorname{IntegerPartition}}([4, 1, 1]), {\operatorname{IntegerPartition}}([3, 2, 1]), {\operatorname{IntegerPartition}}([2, 2, 2])\bigr\rbrack
About
Examples2
Checked againstmathlib4 2 agree
CrosswalkOEIS

Implementation

mappedmathlib4packages/oracle/src/mappings.ts

Nat.Partition n enumerated, those with exactly k parts, ordered as IntegerPartitions

See also: IntegerPartitions, PartitionsInBox