OFFSET
1,3
COMMENTS
Each partition lambda is represented as a list [p_1, m_1, p_2, m_2, ...] where p_i is the part value and m_i is its multiplicity.
The first term of row n is n itself, allowing the row to be decoded without external knowledge of n. (To support the sequence, we have also provided a decoder for Python.)
EXAMPLE
Triangle starts:
[1] 1, 1;
[2] 2, 1, 1, 2;
[3] 3, 1, 2, 1, 1, 1, 1, 3;
[4] 4, 1, 3, 1, 1, 1, 2, 2, 2, 1, 1, 2, 1, 4;
[5] 5, 1, 4, 1, 1, 1, 3, 1, 2, 1, 3, 1, 1, 2, 2, 2, 1, 1, 2, 1, 1, 3, 1, 5;
MAPLE
RunLength := proc(P) local row, p, i, val, count, idx;
if P = [[]] then return [] fi;
row := table(); idx := 1;
for p in P do
if nops(p) > 0 then
val := p[1]; count := 1;
for i from 2 to nops(p) do
if p[i] = val then count := count + 1;
else row[idx] := val; row[idx+1] := count;
idx := idx + 2; val := p[i]; count := 1;
fi od;
row[idx] := val; row[idx+1] := count;
idx := idx + 2;
fi od; return [seq(row[i], i = 1..idx - 1)] end:
A395698row := n -> RunLength(A334439row(n)):
MATHEMATICA
A334439row[n_] := Flatten[ Table[ Tally /@ IntegerPartitions[n, {k}], {k, 1, n} ] ]
Do[Print[A334439row[n]], {n, 1, 9}]
PROG
(SageMath)
def A334439row(n: int) -> list[int]:
row = []
for k in range(n + 1):
for p in Partitions(n, length=k):
for part, cnt in p.to_exp_dict().items():
row.append(part)
row.append(cnt)
return row
for n in range(1, 10): print(A334439row(n))
(Python)
from itertools import groupby
def A334439rle(P: list[list[int]]) -> list[int]:
if P == [[]]: return []
out = []; append = out.append
for p in P:
if p:
for val, grp in groupby(p):
append(val)
append(sum(1 for _ in grp))
return out
def A395698row(n: int) -> list[int]: return A334439rle(A334439row(n))
for n in range(1, 10): print(A395698row(n))
# Decodes the RLE data by extracting n from the first element.
def decoder(data: list[int]) -> list[list[int]]:
if not data: return [[]]
n = data[0]
partitions = []
cur_part = []
cur_sum = 0
for i in range(0, len(data), 2):
val = data[i]
count = data[i+1]
cur_part.extend([val] * count)
cur_sum += val * count
if cur_sum == n:
partitions.append(cur_part)
cur_part = []
cur_sum = 0
return partitions
CROSSREFS
KEYWORD
nonn,tabf
AUTHOR
Peter Luschny, May 04 2026
STATUS
approved
