A120909
Triangle read by rows: T(n,k) is the number of ternary words of length n having k runs (i.e., subwords of maximal length) of identical letters (1 <= k <= n).
Original entry on oeis.org
3, 3, 6, 3, 12, 12, 3, 18, 36, 24, 3, 24, 72, 96, 48, 3, 30, 120, 240, 240, 96, 3, 36, 180, 480, 720, 576, 192, 3, 42, 252, 840, 1680, 2016, 1344, 384, 3, 48, 336, 1344, 3360, 5376, 5376, 3072, 768, 3, 54, 432, 2016, 6048, 12096, 16128, 13824, 6912, 1536, 3, 60
Offset: 1
T(3,2)=12 because we have 001,002,011,022,100,110,112,122,200,211,220 and 221.
Triangle starts:
3;
3, 6;
3, 12, 12;
3, 18, 36, 24;
3, 24, 72, 96, 48;
-
T:=(n,k)->3*2^(k-1)*binomial(n-1,k-1): for n from 1 to 11 do seq(T(n,k),k=1..n) od; # yields sequence in triangular form
-
nn=15;f[list_]:=Select[list,#>0&];a=y x/(1-x) +1;b=a^2/(1-(a-1)^2 );Drop[Map[f,CoefficientList[Series[b a/(1-(a-1)(b-1)),{x,0,nn}],{x,y}]],1]//Grid (* Geoffrey Critzer, Nov 20 2012 *)
A381349
Triangle read by rows: T(n,k) is the number of distinct tuples E each corresponding to some k-ary word W = (w_1, ..., w_n), where E is a tuple (e_1, ..., e_{n-1}) with e_i being the number of pairs of equal letters (w_j,w_k) in W such that j + i = k.
Original entry on oeis.org
1, 1, 2, 1, 3, 4, 1, 6, 9, 10, 1, 10, 22, 26, 27, 1, 20, 54, 73, 78, 79, 1, 36, 163, 249, 269, 275, 276, 1, 72, 447, 791, 915, 942, 949, 950, 1, 135, 1350, 3136, 3776, 3899, 3934, 3942, 3943, 1, 272, 4088, 11315, 14849, 15650, 15811, 15855, 15864, 15865
Offset: 1
Triangle begins:
k=1 2 3 4 5 6 7
n=1 1;
n=2 1, 2;
n=3 1, 3, 4;
n=4 1, 6, 9, 10;
n=5 1, 10, 22, 26, 27;
n=6 1, 20, 54, 73, 78, 79;
n=7 1, 36, 163, 249, 269, 275, 276;
...
Considering the pairs of equal letters in W = (1,3,3,1) there is 1 pair with no letters between them, 0 pairs with a single letter between them, and 1 pair seperated by two letters, giving E = (1,0,1).
T(4,2) = 6 counts the following values of E each listed with a corresponding word:
E W
(3,2,1) (1,1,1,1)
(2,1,0) (1,1,1,2)
(2,0,0) (1,1,2,2)
(1,0,1) (1,2,2,1)
(1,1,1) (2,1,2,2)
(0,2,0) (2,1,2,1)
-
from itertools import combinations_with_replacement, permutations
def pairs(m): return tuple([sum(1 for j in range(len(m)-i) if m[j] == m[j+i]) for i in range(1,len(m))])
def A381349(n,k):
S = set()
for y in combinations_with_replacement(range(1,k+1),n-1):
S.update(z for z in permutations((1,)+y))
return len({pairs(i) for i in S})
-
# see links for a different algorithm
from sympy.utilities.iterables import multiset_permutations
from itertools import combinations, combinations_with_replacement
def E(w):
return tuple(sum(1 for j, k in combinations(range(len(w)), 2) if w[j] == w[k] and j+i == k) for i in range(len(w)))
def row(n): # generator of row n
v, S = 0, set()
for k in range(1, n+1):
for c in combinations_with_replacement(range(1, k+1), n-k):
if len(c) > 0 and c[0] == 2: break
S.update(E(e) for e in multiset_permutations(tuple(range(1, k+1))+c))
yield len(S)
print([e for n in range(1, 9) for e in row(n)]) # Michael S. Branicky, Feb 26 2025
Showing 1-2 of 2 results.
Comments