Skip to content

PalindromicCompositions ​

The compositions of nn that read the same forwards and backwards.

PalindromicCompositions(n)the compositions of nn that read the same forwards and backwards
Typed signatures
TypePackageApplies
(integer<0..>) -> indexed_collection<composition>combinatoricsalways

Domain: Collections

Details
  • Count is 2⌊n/2⌋2^{\lfloor n/2 \rfloor} (A016116).

Definition

Epsil, as the implementation runs it.

count(_n)

2 ^ ((_n - _n % 2) / 2)

unrank(_n, _r)

Apply(
       (pa_s: list<integer>) => Apply(
                                       (pa_left: list<integer>) => Apply((pa_len: integer) => Join(
                                                                                                    pa_left,
                                                                                                    [] if pa_s[3] == 0 else [pa_s[3]],
                                                                                                    Map(
                                                                                                         Function(pa_left[pa_len - pa_j +
                                                                                                                          1], pa_j),
                                                                                                         Range(1, pa_len, 1),
                                                                                                       ),
                                                                                                  ), Length(pa_left)),
                                       Drop(pa_s, 3),
                                     ),
       Fold(
             Function(Apply((pa_m: integer) => Apply((pa_r: integer) => Apply(
                                                                               (pa_h: integer) => pa_u if pa_m == 0 else Apply(
                                                                                                                                (pa_a: integer) => Join([
                                                                                                                                                          pa_m - 2pa_a,
                                                                                                                                                          pa_r -
                                                                                                                                                          (2 ^ pa_h -
                                                                                                                                                           2 ^
                                                                                                                                                           (pa_h + 1 -
                                                                                                                                                            pa_a)),
                                                                                                                                                          pa_u[3],
                                                                                                                                                        ], Drop(pa_u, 3), [pa_a]),
                                                                                                                                Fold(
                                                                                                                                      Function(pa_j if pa_r <
                                                                                                                                                       2 ^ pa_h -
                                                                                                                                                       2 ^
                                                                                                                                                       (pa_h + 1 -
                                                                                                                                                        (pa_j + 1)) else pa_f, pa_f, pa_j),
                                                                                                                                      pa_h,
                                                                                                                                      Range(pa_h, 1, -1),
                                                                                                                                    ),
                                                                                                                              ) if pa_r <
                                                                                                                                  2 ^ pa_h -
                                                                                                                                  1 else Join([0, pa_r -
                                                                                                                                                 (2 ^ pa_h -
                                                                                                                                                  1), pa_m], Drop(pa_u, 3)),
                                                                               (pa_u[1] -
                                                                                pa_u[1] % 2) /
                                                                               2,
                                                                             ), pa_u[2]), pa_u[1]), pa_u, pa_i),
             [_n, _r, 0],
             Range(1, _n, 1),
           ),
     )

rank(_n, _x)

Fold(
      Function(Apply((pa_r: integer) => Apply((pa_m: integer) => Apply(
                                                                        (pa_h: integer) => pa_a if pa_a[3] == 1 ||
                                                                                                   pa_m == 0 else [pa_r +
                                                                                                          (2 ^ pa_h -
                                                                                                           1), 0, 1] if _x[pa_j] == pa_m else [pa_r +
                                                                                                                                            (2 ^ pa_h -
                                                                                                                                             2 ^
                                                                                                                                             (pa_h + 1 -
                                                                                                                                              _x[pa_j])), pa_m -
                                                                                                                                              2 * _x[pa_j], 0],
                                                                        (pa_a[2] -
                                                                         pa_a[2] %
                                                                         2) / 2,
                                                                      ), pa_a[2]), pa_a[1]), pa_a, pa_j),
      [0, _n, 0],
      Range(1, Length(_x), 1),
    )[1]

valid(_n, _x)

Fold(Function(pa_t + pa_v, pa_t, pa_v), 0, _x) == _n && Fold(
                                                              Function(
                                                                        ok_pa_g &&
                                                                        _x[pa_g] >=
                                                                        1,
                                                                        ok_pa_g,
                                                                        pa_g,
                                                                      ),
                                                              True,
                                                              Range(
                                                                     1,
                                                                     Length(_x),
                                                                     1,
                                                                   ),
                                                            ) && Fold(
                                                                      Function(ok_pa_k &&
                                                                               _x[pa_k] ==
                                                                               _x[Length(_x) - pa_k +
                                                                                  1], ok_pa_k, pa_k),
                                                                      True,
                                                                      Range(
                                                                             1,
                                                                             Length(_x),
                                                                             1,
                                                                           ),
                                                                    )

Statistics

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

Maps

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

From IntegerComposition

  • CodeWordIntegerComposition → BinaryWordInjectionGraded mapMp00094The word that writes each part i as a one followed by i - 1 zeros.
  • ComplementIntegerComposition → IntegerCompositioninvolutionBijectionGraded mapInvolutionMp00039The composition cut exactly where this one is not: its cut set complemented.
  • CompositionBouncePathIntegerComposition → DyckPathInjectionGraded mapMp00231The Dyck path that bounces off the diagonal once for each part: a run of that many ups, then as many downs.
  • CutWordIntegerComposition → BinaryWordinverseA composition of n as the binary word of length n - 1 marking where it is cut.
  • CyclicShiftIntegerComposition → IntegerCompositioninverseBijectionGraded mapMp00173Rotate the parts one place to the left: the first part moves to the end.
  • DeltaMorphismIntegerComposition → IntegerCompositionSurjectionMp00133The lengths of the maximal runs of equal parts, left to right.
  • FoataInversionsToMajorIntegerComposition → IntegerCompositionbijectioninverseBijectionGraded mapMp00315The inverse of Foata's bijection on compositions: peel off the last part, rotate the blocks of the rest back.
  • FoataMajorToInversionsIntegerComposition → IntegerCompositionbijectioninverseBijectionGraded mapMp00314Foata's bijection on the word of parts: each part is put on the end of the image so far, which is cut into blocks, and every block is rotated one place right.
  • InverseCyclicShiftIntegerComposition → IntegerCompositioninverseBijectionGraded mapMp00172Rotate the parts one place to the right: the last part moves to the front.
  • ReverseIntegerComposition → IntegerCompositioninvolutionBijectionGraded mapInvolutionMp00038The parts read backwards.
  • SortedPartitionIntegerComposition → IntegerPartitionsurjectionSurjectionGraded mapMp00040The partition a composition's parts form, sorted largest first.
  • TransposeCompositionIntegerComposition → IntegerCompositioninvolutionBijectionGraded mapInvolutionMp00041The conjugate composition: its ribbon shape transposed, the complement of the reverse.

To IntegerComposition

  • BlockSizeCompositionSetPartition → IntegerCompositionsurjectionSurjectionGraded mapMp00128The block sizes of a set partition, its blocks taken in order of their least elements.
  • BlockSizeCompositionSetComposition → IntegerCompositionsurjectionSurjectionGraded mapMp00287The block sizes of a set composition, its blocks taken in order.
  • CodeCompositionBinaryWord → IntegerCompositionInjectionGraded mapMp00178The composition whose code is the word with a 1 put in front: each 1 opens a part, of 1 plus the zeros after it.
  • DescentCompositionPermutation → IntegerCompositionsurjectionSurjectionGraded mapMp00071The composition of n cut at the descent positions.
  • IntegerCompositionBinaryWord → IntegerCompositioninverseThe composition of m + 1 a binary word of length m cuts out.
  • PeakCompositionStandardTableau → IntegerCompositionGraded mapMp00294The composition cut at the peaks: entries i that are descents after an ascent.
  • RiseCompositionDyckPath → IntegerCompositionsurjectionSurjectionGraded mapMp00102The lengths of the maximal runs of up steps, left to right.
  • RunCompositionBinaryWord → IntegerCompositionsurjectionSurjectionGraded mapMp00097The lengths of the maximal runs of equal letters, left to right.
  • TouchCompositionDyckPath → IntegerCompositionsurjectionSurjectionGraded mapMp00100The semilengths of the primitive pieces between a path's returns to the diagonal.
  • ValleyCompositionStandardTableau → IntegerCompositionGraded mapMp00295The composition cut at the valleys: entries i that are ascents after a descent.
10 more in FindStat, not implemented here
  • Mp00054ParkingFunction → IntegerCompositionSurjectionGraded mapto inverse des composition
  • Mp00057ParkingFunction → IntegerCompositionSurjectionGraded mapto touch composition
  • Mp00152LabeledGraph → IntegerCompositionSurjectionGraded mapLaplacian multiplicities
  • Mp00180IntegerComposition → SkewPartitionInjectionGraded mapto ribbon
  • Mp00181SkewPartition → IntegerCompositionSurjectionGraded maprow lengths
  • Mp00184IntegerComposition → LabeledGraphInjectionGraded mapto threshold graph
  • Mp00207StandardTableau → IntegerCompositionSurjectionGraded maphorizontal strip sizes
  • Mp00248Permutation → IntegerCompositionGraded mapDEX composition
  • Mp00319ParkingFunction → IntegerCompositionInjectionto composition
  • Mp00324LabeledGraph → IntegerCompositionGraded mapchromatic difference sequence

Enumeration

Examples

1 more kept as data, checked against the oracles
Basic #

Count(PalindromicCompositions(6))=8Count(PalindromicCompositions(6)) = 8

live ↗
InCount(PalindromicCompositions(6))\mathrm{Count}(\mathrm{PalindromicCompositions}(6))Out88

The first element in enumeration order

live ↗
InPalindromicCompositions(6)[1]\mathrm{PalindromicCompositions}(6)[1]OutIntegerComposition⁡([1,1,1,1,1,1]){\operatorname{IntegerComposition}}([1, 1, 1, 1, 1, 1])
About
Examples3
CrosswalkOEIS

See also: IntegerCompositions