A124762 Number of levels for compositions in standard order.
0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 1, 1, 0, 0, 1, 3, 0, 0, 0, 1, 0, 1, 0, 2, 0, 0, 1, 1, 1, 1, 2, 4, 0, 0, 0, 1, 1, 0, 0, 2, 0, 0, 2, 2, 0, 0, 1, 3, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 2, 2, 2, 3, 5, 0, 0, 0, 1, 0, 0, 0, 2, 0, 1, 1, 1, 0, 0, 1, 3, 0, 0, 0, 1, 1, 2, 1, 3, 0, 0, 1, 1, 1, 1, 2, 4, 0, 0, 0, 1, 1, 0, 0, 2, 0
Offset: 0
Examples
Composition number 11 is 2,1,1; 2>1=1, so a(11) = 1. The table starts: 0 0 0 1 0 0 0 2 0 0 1 1 0 0 1 3 0 0 0 1 0 1 0 2 0 0 1 1 1 1 2 4 0 0 0 1 1 0 0 2 0 0 2 2 0 0 1 3 0 0 0 1 0 1 0 2 1 1 2 2 2 2 3 5
Crossrefs
Anti-runs summing to n are counted by A003242(n).
A triangle counting maximal anti-runs of compositions is A106356.
A triangle counting maximal runs of compositions is A238279.
Partitions whose first differences are an anti-run are A238424.
All of the following pertain to compositions in standard order (A066099):
- Weakly decreasing runs are counted by A124765.
- Weakly increasing runs are counted by A124766.
- Equal runs are counted by A124767.
- Strictly increasing runs are counted by A124768.
- Strictly decreasing runs are counted by A124769.
- Strict compositions are A233564.
- Constant compositions are A272919.
- Normal compositions are A333217.
- Adjacent unequal pairs are counted by A333382.
- Anti-runs are A333489.
Programs
-
Mathematica
stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse; Table[Length[Select[Partition[stc[n],2,1],SameQ@@#&]],{n,0,100}] (* Gus Wiseman, Apr 08 2020 *)
Formula
For a composition b(1),...,b(k), a(n) = Sum_{1<=i=1
For n > 0, a(n) = A333381(n) - 1. - Gus Wiseman, Apr 08 2020
A345167 Numbers k such that the k-th composition in standard order is alternating.
0, 1, 2, 4, 5, 6, 8, 9, 12, 13, 16, 17, 18, 20, 22, 24, 25, 32, 33, 34, 38, 40, 41, 44, 45, 48, 49, 50, 54, 64, 65, 66, 68, 70, 72, 76, 77, 80, 81, 82, 88, 89, 96, 97, 98, 102, 108, 109, 128, 129, 130, 132, 134, 140, 141, 144, 145, 148, 152, 153, 160, 161, 162
Offset: 1
Keywords
Comments
The k-th composition in standard order (graded reverse-lexicographic, A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again. This gives a bijective correspondence between nonnegative integers and integer compositions.
A sequence is alternating if it is alternately strictly increasing and strictly decreasing, starting with either. For example, the partition (3,2,2,2,1) has no alternating permutations, even though it does have the anti-run permutations (2,3,2,1,2) and (2,1,2,3,2).
Examples
The terms together with their binary indices begin: 1: (1) 25: (1,3,1) 66: (5,2) 2: (2) 32: (6) 68: (4,3) 4: (3) 33: (5,1) 70: (4,1,2) 5: (2,1) 34: (4,2) 72: (3,4) 6: (1,2) 38: (3,1,2) 76: (3,1,3) 8: (4) 40: (2,4) 77: (3,1,2,1) 9: (3,1) 41: (2,3,1) 80: (2,5) 12: (1,3) 44: (2,1,3) 81: (2,4,1) 13: (1,2,1) 45: (2,1,2,1) 82: (2,3,2) 16: (5) 48: (1,5) 88: (2,1,4) 17: (4,1) 49: (1,4,1) 89: (2,1,3,1) 18: (3,2) 50: (1,3,2) 96: (1,6) 20: (2,3) 54: (1,2,1,2) 97: (1,5,1) 22: (2,1,2) 64: (7) 98: (1,4,2) 24: (1,4) 65: (6,1) 102: (1,3,1,2)
Links
- Wikipedia, Alternating permutation
Crossrefs
The complement is A345168.
Factorizations with a permutation of this type: A348379.
A003242 counts anti-run compositions.
A345164 counts alternating permutations of prime indices.
Statistics of standard compositions:
- Length is A000120.
- Constant runs are A124767.
- Heinz number is A333219.
- Number of maximal anti-runs is A333381.
- Runs-resistance is A333628.
- Number of distinct parts is A334028.
Classes of standard compositions:
- Weakly decreasing compositions (partitions) are A114994.
- Weakly increasing compositions (multisets) are A225620.
- Anti-runs are A333489.
- Non-alternating anti-runs are A345169.
Programs
-
Mathematica
stc[n_]:=Differences[Prepend[Join@@Position[ Reverse[IntegerDigits[n,2]],1],0]]//Reverse; wigQ[y_]:=Or[Length[y]==0,Length[Split[y]] ==Length[y]&&Length[Split[Sign[Differences[y]]]]==Length[y]-1]; Select[Range[0,100],wigQ@*stc]
A374249 Numbers k such that the k-th composition in standard order has its equal parts contiguous.
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 26, 28, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 47, 48, 50, 52, 56, 58, 60, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 78, 79, 80, 81, 83, 84, 85
Offset: 1
Keywords
Comments
These are compositions avoiding the patterns (1,2,1) and (2,1,2).
The k-th composition in standard order (graded reverse-lexicographic, A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again. This gives a bijective correspondence between nonnegative integers and integer compositions.
Examples
The terms together with their standard compositions begin: 0: () 1: (1) 2: (2) 3: (1,1) 4: (3) 5: (2,1) 6: (1,2) 7: (1,1,1) 8: (4) 9: (3,1) 10: (2,2) 11: (2,1,1) 12: (1,3) 14: (1,1,2) 15: (1,1,1,1) 16: (5) See A374253 for the complement: 13, 22, 25, 27, 29, ...
Links
Crossrefs
Compositions of this type are counted by A274174.
Permutations of prime indices of this type are counted by A333175.
A011782 counts compositions.
A066099 lists compositions in standard order.
A333755 counts compositions by number of runs.
A335454 counts patterns matched by standard compositions.
A335462 counts (1,2,1)- and (2,1,2)-matching permutations of prime indices.
Programs
-
Mathematica
stc[n_]:=Differences[Prepend[Join @@ Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse; Select[Range[0,100],UnsameQ@@First/@Split[stc[#]]&]
A333382 Number of adjacent unequal parts in the n-th composition in standard-order.
0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 2, 1, 0, 0, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 0, 0, 1, 1, 1, 0, 2, 2, 1, 1, 2, 0, 1, 2, 3, 2, 1, 1, 2, 2, 2, 2, 2, 3, 2, 1, 2, 1, 2, 1, 2, 1, 0, 0, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 3, 2, 1, 1, 2, 2, 2, 1, 1, 2
Offset: 0
Keywords
Comments
A composition of n is a finite sequence of positive integers summing to n. The k-th composition in standard order (row k of A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again.
For n > 0, a(n) is one fewer than the number of maximal runs of the n-th composition in standard-order.
Examples
The 46th composition in standard order is (2,1,1,2), with maximal runs ((2),(1,1),(2)), so a(46) = 3 - 1 = 2.
Links
- Wikipedia, Longest increasing subsequence
Crossrefs
Indices of first appearances (not counting 0) are A113835.
Partitions whose 0-appended first differences are a run are A007862.
Partitions whose first differences are a run are A049988.
A triangle counting maximal anti-runs of compositions is A106356.
A triangle counting maximal runs of compositions is A238279.
All of the following pertain to compositions in standard order (A066099):
- Adjacent equal pairs are counted by A124762.
- Weakly decreasing runs are counted by A124765.
- Weakly increasing runs are counted by A124766.
- Equal runs are counted by A124767.
- Strictly increasing runs are counted by A124768.
- Strictly decreasing runs are counted by A124769.
- Strict compositions are ranked by A233564.
- Constant compositions are ranked by A272919.
- Normal compositions are ranked by A333217.
- Anti-runs are ranked by A333489.
- Anti-runs are counted by A333381.
Programs
-
Mathematica
stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse; Table[Length[Select[Partition[stc[n],2,1],UnsameQ@@#&]],{n,0,100}]
Formula
For n > 0, a(n) = A124767(n) - 1.
A345192 Number of non-alternating compositions of n.
0, 0, 1, 1, 4, 9, 20, 45, 99, 208, 437, 906, 1862, 3803, 7732, 15659, 31629, 63747, 128258, 257722, 517339, 1037652, 2079984, 4167325, 8346204, 16710572, 33449695, 66944254, 133959021, 268028868, 536231903, 1072737537, 2145905285, 4292486690, 8586035993, 17173742032, 34350108745, 68704342523, 137415168084
Offset: 0
Keywords
Comments
A sequence is alternating if it is alternately strictly increasing and strictly decreasing, starting with either. For example, the partition (3,2,2,2,1) has no alternating permutations, even though it does have the anti-run permutations (2,3,2,1,2) and (2,1,2,3,2).
Examples
The a(2) = 1 through a(6) = 20 compositions: (11) (111) (22) (113) (33) (112) (122) (114) (211) (221) (123) (1111) (311) (222) (1112) (321) (1121) (411) (1211) (1113) (2111) (1122) (11111) (1131) (1221) (1311) (2112) (2211) (3111) (11112) (11121) (11211) (12111) (21111) (111111)
Links
- Andrew Howroyd, Table of n, a(n) for n = 0..1000
Crossrefs
The case without twins is A348377.
The version for factorizations is A348613.
A003242 counts anti-run compositions.
A011782 counts compositions.
A032020 counts strict compositions.
A106356 counts compositions by number of maximal anti-runs.
A114901 counts compositions where each part is adjacent to an equal part.
A274174 counts compositions with equal parts contiguous.
A344604 counts alternating compositions with twins.
A344605 counts alternating patterns with twins.
A344654 counts non-twin partitions with no alternating permutation.
A345162 counts normal partitions with no alternating permutation.
A345164 counts alternating permutations of prime indices.
Patterns:
- A128761 avoiding (1,2,3) adjacent.
- A344614 avoiding (1,2,3) and (3,2,1) adjacent.
- A344615 weakly avoiding (1,2,3) adjacent.
Programs
-
Mathematica
wigQ[y_]:=Or[Length[y]==0,Length[Split[y]]== Length[y]&&Length[Split[Sign[Differences[y]]]]==Length[y]-1]; Table[Length[Select[Join@@Permutations/@IntegerPartitions[n],!wigQ[#]&]],{n,0,15}]
A261982 Number of compositions of n with some part repeated.
0, 0, 1, 1, 5, 11, 21, 51, 109, 229, 455, 959, 1947, 3963, 7999, 16033, 32333, 64919, 130221, 260967, 522733, 1045825, 2093855, 4189547, 8382315, 16768455, 33543127, 67093261, 134193413, 268404995, 536829045, 1073686083, 2147408773, 4294869253, 8589803783
Offset: 0
Keywords
Comments
Also compositions matching the pattern (1,1). - Gus Wiseman, Jun 23 2020
Examples
a(2) = 1: 11. a(3) = 1: 111. a(4) = 5: 22, 211, 121, 112, 1111.
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..3322
- Wikipedia, Permutation pattern
- Gus Wiseman, Sequences counting and ranking compositions by the patterns they match or avoid.
Crossrefs
Programs
-
Maple
b:= proc(n, k) option remember; `if`(k<0 or n<0, 0, `if`(k=0, `if`(n=0, 1, 0), b(n-k, k) +k*b(n-k, k-1))) end: a:= n-> ceil(2^(n-1))-add(b(n, k), k=0..floor((sqrt(8*n+1)-1)/2)): seq(a(n), n=0..40);
-
Mathematica
b[n_, k_] := b[n, k] = If[k<0 || n<0, 0, If[k==0, If[n==0, 1, 0], b[n-k, k] + k*b[n-k, k-1]]]; a[n_] := Ceiling[2^(n-1)]-Sum[b[n, k], {k, 0, Floor[ (Sqrt[8n+1]-1)/2]}]; Table[a[n], {n, 0, 40}] (* Jean-François Alcover, Feb 08 2017, translated from Maple *) Table[Length[Join@@Permutations/@Select[IntegerPartitions[n],Length[#]>Length[Split[#]]&]],{n,0,10}] (* Gus Wiseman, Jun 24 2020 *)
Formula
G.f.: (1 - x) / (1 - 2*x) - Sum_{k>=0} k! * x^(k*(k + 1)/2) / Product_{j=1..k} (1 - x^j). - Ilya Gutkovskiy, Jan 30 2020
A373948 Run-compression encoded as a transformation of compositions in standard order.
0, 1, 2, 1, 4, 5, 6, 1, 8, 9, 2, 5, 12, 13, 6, 1, 16, 17, 18, 9, 20, 5, 22, 5, 24, 25, 6, 13, 12, 13, 6, 1, 32, 33, 34, 17, 4, 37, 38, 9, 40, 41, 2, 5, 44, 45, 22, 5, 48, 49, 50, 25, 52, 13, 54, 13, 24, 25, 6, 13, 12, 13, 6, 1, 64, 65, 66, 33, 68, 69, 70, 17, 72
Offset: 0
Keywords
Comments
The k-th composition in standard order (graded reverse-lexicographic, A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again. This gives a bijective correspondence between nonnegative integers and integer compositions.
We define the (run-) compression of a sequence to be the anti-run obtained by reducing each run of repeated parts to a single part. Alternatively, compression removes all parts equal to the part immediately to their left. For example, (1,1,2,2,1) has compression (1,2,1).
For the present sequence, the a(n)-th composition in standard order is obtained by compressing the n-th composition in standard order.
Examples
The standard compositions and their compressions begin: 0: () --> 0: () 1: (1) --> 1: (1) 2: (2) --> 2: (2) 3: (1,1) --> 1: (1) 4: (3) --> 4: (3) 5: (2,1) --> 5: (2,1) 6: (1,2) --> 6: (1,2) 7: (1,1,1) --> 1: (1) 8: (4) --> 8: (4) 9: (3,1) --> 9: (3,1) 10: (2,2) --> 2: (2) 11: (2,1,1) --> 5: (2,1) 12: (1,3) --> 12: (1,3) 13: (1,2,1) --> 13: (1,2,1) 14: (1,1,2) --> 6: (1,2) 15: (1,1,1,1) --> 1: (1)
Links
Crossrefs
Programs
-
Mathematica
stc[n_]:=Differences[Prepend[Join @@ Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse; stcinv[q_]:=Total[2^(Accumulate[Reverse[q]])]/2; Table[stcinv[First/@Split[stc[n]]],{n,0,30}]
A351014 Number of distinct runs in the n-th composition in standard order.
0, 1, 1, 1, 1, 2, 2, 1, 1, 2, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 3, 2, 1, 1, 2, 2, 2, 1, 3, 3, 2, 2, 3, 1, 2, 3, 2, 2, 2, 2, 2, 3, 3, 3, 2, 2, 3, 2, 3, 2, 2, 2, 3, 2, 1, 1, 2, 2, 2, 2, 3, 3, 2, 2, 2, 2, 3, 2, 3, 3, 2, 2, 3, 2, 3, 2, 2, 3
Offset: 0
Keywords
Comments
The n-th composition in standard order (graded reverse-lexicographic, A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of n, prepending 0, taking first differences, and reversing again. This gives a bijective correspondence between nonnegative integers and integer compositions.
Examples
The number 3310 has binary expansion 110011101110 and standard composition (1,3,1,1,2,1,1,2), with runs (1), (3), (1,1), (2), (1,1), (2), of which 4 are distinct, so a(3310) = 4.
Links
- Mathematics Stack Exchange, What is a sequence run? (answered 2011-12-01)
Crossrefs
Counting not necessarily distinct runs gives A124767.
Using binary expansions instead of standard compositions gives A297770.
Positions of first appearances are A351015.
A005811 counts runs in binary expansion.
A011782 counts integer compositions.
A044813 lists numbers whose binary expansion has distinct run-lengths.
A351204 counts partitions where every permutation has all distinct runs.
Counting words with all distinct runs:
- A351202 = permutations of prime factors.
Selected statistics of standard compositions:
- Length is A000120.
- Sum is A070939.
- Heinz number is A333219.
- Number of distinct parts is A334028.
Selected classes of standard compositions:
- Strict compositions are A233564.
- Constant compositions are A272919.
Programs
-
Mathematica
stc[n_]:=Differences[Prepend[Join@@ Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse; Table[Length[Union[Split[stc[n]]]],{n,0,100}]
A344604 Number of alternating compositions of n, including twins (x,x).
1, 1, 2, 3, 5, 7, 13, 19, 30, 48, 76, 118, 187, 293, 461, 725, 1140, 1789, 2815, 4422, 6950, 10924, 17169, 26979, 42405, 66644, 104738, 164610, 258708, 406588, 639010, 1004287, 1578364, 2480606, 3898600, 6127152, 9629624, 15134213, 23785389, 37381849, 58750469
Offset: 0
Keywords
Comments
We define a composition to be alternating including twins (x,x) if there are no adjacent triples (..., x, y, z, ...) where x <= y <= z or x >= y >= z. Except in the case of twins (x,x), all such compositions are anti-runs (A003242). These compositions avoid the weak consecutive patterns (1,2,3) and (3,2,1), the strict version being A344614.
The version without twins (x,x) is A025047 (alternating compositions).
Examples
The a(1) = 1 through a(7) = 19 compositions: (1) (2) (3) (4) (5) (6) (7) (11) (12) (13) (14) (15) (16) (21) (22) (23) (24) (25) (31) (32) (33) (34) (121) (41) (42) (43) (131) (51) (52) (212) (132) (61) (141) (142) (213) (151) (231) (214) (312) (232) (1212) (241) (2121) (313) (412) (1213) (1312) (2131) (3121) (12121)
Links
- Andrew Howroyd, Table of n, a(n) for n = 0..1000
Crossrefs
A001250 counts alternating permutations.
A005649 counts anti-run patterns.
A106356 counts compositions by number of maximal anti-runs.
A114901 counts compositions where each part is adjacent to an equal part.
A325534 counts separable partitions.
A325535 counts inseparable partitions.
A344605 counts alternating patterns including twins.
A344606 counts alternating permutations of prime factors including twins.
Counting compositions by patterns:
- A011782 no conditions.
- A003242 avoiding (1,1) adjacent.
- A102726 avoiding (1,2,3).
- A106351 avoiding (1,1) adjacent by sum and length.
- A128695 avoiding (1,1,1) adjacent.
- A128761 avoiding (1,2,3) adjacent.
- A232432 avoiding (1,1,1).
- A335456 all patterns.
- A335457 all patterns adjacent.
- A335514 matching (1,2,3).
- A344614 avoiding (1,2,3) and (3,2,1) adjacent.
- A344615 weakly avoiding (1,2,3) adjacent.
Programs
Formula
Extensions
a(21)-a(40) from Alois P. Heinz, Nov 04 2021
A344614 Number of compositions of n with no adjacent triples (..., x, y, z, ...) where x < y < z or x > y > z.
1, 1, 2, 4, 8, 16, 30, 58, 110, 209, 397, 753, 1429, 2711, 5143, 9757, 18511, 35117, 66621, 126389, 239781, 454897, 863010, 1637260, 3106138, 5892821, 11179603, 21209446, 40237641, 76337091, 144823431, 274752731, 521249018, 988891100, 1876081530, 3559220898, 6752400377
Offset: 0
Keywords
Comments
These compositions avoid the strict consecutive patterns (1,2,3) and (3,2,1), the weak version being A344604.
Examples
The a(6) = 30 compositions are: (6) (15) (114) (1113) (11112) (111111) (24) (132) (1122) (11121) (33) (141) (1131) (11211) (42) (213) (1212) (12111) (51) (222) (1221) (21111) (231) (1311) (312) (2112) (411) (2121) (2211) (3111) Missing are: (123), (321).
Crossrefs
A001250 counts alternating permutations.
A005649 counts anti-run patterns.
A106356 counts compositions by number of maximal anti-runs.
A114901 counts compositions where each part is adjacent to an equal part.
A325534 counts separable partitions.
A325535 counts inseparable partitions.
A344604 counts wiggly compositions with twins.
A344605 counts wiggly patterns with twins.
A344606 counts wiggly permutations of prime factors with twins.
Counting compositions by patterns:
- A003242 avoiding (1,1) adjacent.
- A011782 no conditions.
- A106351 avoiding (1,1) adjacent by sum and length.
- A128695 avoiding (1,1,1) adjacent.
- A128761 avoiding (1,2,3).
- A232432 avoiding (1,1,1).
- A335456 all patterns.
- A335457 all patterns adjacent.
- A335514 matching (1,2,3).
- A344604 weakly avoiding (1,2,3) and (3,2,1) adjacent.
- A344614 avoiding (1,2,3) and (3,2,1) adjacent.
- A344615 weakly avoiding (1,2,3) adjacent.
Programs
Extensions
More terms from Bert Dobbelaere, Jun 12 2021
Comments