Skip to content

LongestKOneTwoPattern ​

The largest k such that p has an occurrence of k 1 2 ... (k-1): a first entry above an increasing run of later, smaller ones.

✓ checked against that system · ! checked, with disagreements (hover a chip)FindStatSt000451via Permutation✓
LongestKOneTwoPattern(p)The largest k such that p has an occurrence of k 1 2 ... (k-1): a first entry above an increasing run of later, smaller ones.
Typed signatures
TypePackageApplies
(list<integer> | permutation) -> numbercombinatoricsalways

Domain: Permutation statistics

Details
  • Defined over Permutation as an expression in _x, evaluated by compute-engine — the definition IS the implementation.
  • Takes a Permutation, and also a bare list of integers: this reading compares entries with each other rather than with their positions, so it stands on any sequence.

Definition

Epsil, as the implementation runs it.

on Permutation, over _x

1 if Length(_x) < 1 else 1 + Max(Map(Function(Count(Fold(
                                                          Function(Apply(
                                                                          Function(
                                                                                    Join(a, [_x[b]]) if k > Count(a) else ReplaceAt(a, k, _x[b]),
                                                                                    k,
                                                                                  ),
                                                                          Count(Filter(a, Function(t < _x[b], t))) +
                                                                          1,
                                                                        ) if b >
                                                                            i &&
                                                                            _x[b] <
                                                                            _x[i] else a, a, b),
                                                          [],
                                                          Range(1, Length(_x)),
                                                        )), i), Range(
                                                                      1,
                                                                      Length(_x),
                                                                    )))

Examples

Basic #

the one-line word 312312

live ↗
InLongestKOneTwoPattern(Permutation⁡([3,1,2]))\mathrm{LongestKOneTwoPattern}({\operatorname{Permutation}}([3, 1, 2]))Out33

the one-line word 312312, as a plain list

live ↗
InLongestKOneTwoPattern([3,1,2])\mathrm{LongestKOneTwoPattern}(\bigl\lbrack3, 1, 2\bigr\rbrack)Out33

the one-line word 24132413

live ↗
InLongestKOneTwoPattern(Permutation⁡([2,4,1,3]))\mathrm{LongestKOneTwoPattern}({\operatorname{Permutation}}([2, 4, 1, 3]))Out33
Properties #

FindStat's value for [1]

live ↗
InCombinatorialStat(Permutation⁡([1]),LongestKOneTwoPattern)\mathrm{CombinatorialStat}({\operatorname{Permutation}}([1]), \text{LongestKOneTwoPattern})Out11

Known value · FindStat St000451

FindStat's value for [1,2]

live ↗
InCombinatorialStat(Permutation⁡([1,2]),LongestKOneTwoPattern)\mathrm{CombinatorialStat}({\operatorname{Permutation}}([1, 2]), \text{LongestKOneTwoPattern})Out11

Known value · FindStat St000451

FindStat's value for [2,1]

live ↗
InCombinatorialStat(Permutation⁡([2,1]),LongestKOneTwoPattern)\mathrm{CombinatorialStat}({\operatorname{Permutation}}([2, 1]), \text{LongestKOneTwoPattern})Out22

Known value · FindStat St000451

About
Examples6
CrosswalkFindStat