OFFSET
0,2
COMMENTS
We define a (normal) pattern to be a finite sequence covering an initial interval of positive integers. Patterns are counted by A000670. A sequence S is said to match a pattern P if there is a not necessarily contiguous subsequence of S whose parts have the same relative order as P. For example, (3,1,1,3) matches (1,1,2), (2,1,1), and (2,1,2), but avoids (1,2,1), (1,2,2), and (2,2,1).
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.
LINKS
John Tyler Rascoe, Table of n, a(n) for n = 0..8192
Wikipedia, Permutation pattern
EXAMPLE
The a(n) patterns for n = 0, 1, 3, 7, 11, 13, 23, 83, 27, 45:
0: 1: 11: 111: 211: 121: 2111: 2311: 1211: 2121:
---------------------------------------------------------------------
() () () () () () () () () ()
(1) (1) (1) (1) (1) (1) (1) (1) (1)
(11) (11) (11) (11) (11) (11) (11) (11)
(111) (21) (12) (21) (12) (12) (12)
(211) (21) (111) (21) (21) (21)
(121) (211) (211) (111) (121)
(2111) (231) (121) (211)
(2311) (211) (212)
(1211) (221)
(2121)
MATHEMATICA
stc[n_]:=Reverse[Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n, 2]], 1], 0]]];
mstype[q_]:=q/.Table[Union[q][[i]]->i, {i, Length[Union[q]]}];
Table[Length[Union[mstype/@Subsets[stc[n]]]], {n, 0, 30}]
PROG
(Python)
from itertools import combinations
def comp(n):
# see A357625
return
def A335465(n):
A, B, C = set(), set(), comp(n)
c = range(len(C))
for j in c:
for k in combinations(c, j):
A.add(tuple(C[i] for i in k))
for i in A:
D = {v: rank + 1 for rank, v in enumerate(sorted(set(i)))}
B.add(tuple(D[v] for v in i))
return len(B)+1 # John Tyler Rascoe, Mar 12 2025
CROSSREFS
References found in the links are not all included here.
Summing over indices with binary length n gives A335456(n).
The contiguous case is A335458.
The version for Heinz numbers of partitions is A335549.
The n-th composition has A124771(n) distinct consecutive subsequences.
The n-th composition has A333257(n) distinct subsequence-sums.
The n-th composition has A334299(n) distinct subsequences.
Minimal avoided patterns are counted by A335465.
KEYWORD
nonn,look
AUTHOR
Gus Wiseman, Jun 14 2020
STATUS
approved
