A369492 Triangle read by rows. An encoding of compositions of n where the first part is the largest part and the last part is not 1. The number of these compositions (the length of row n) is given by A368279.
1, 0, 2, 4, 8, 10, 16, 18, 22, 32, 34, 36, 38, 42, 46, 64, 66, 68, 70, 74, 76, 78, 86, 90, 94, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 154, 156, 158, 170, 174, 182, 186, 190, 256, 258, 260, 262, 264, 266, 268, 270, 274, 276, 278, 280, 282, 284, 286
Offset: 0
Examples
Encoding the composition as an integer, a binary string, a Dyck path, and a list. [ n] [ 0] 1 | 1 | () | [()] [ 1] 0 | 0 | . | [] [ 2] 2 | 10 | (()) | [2] [ 3] 4 | 100 | ((())) | [3] [ 4] 8 | 1000 | (((()))) | [4] [ 5] 10 | 1010 | (())(()) | [2, 2] [ 6] 16 | 10000 | ((((())))) | [5] [ 7] 18 | 10010 | ((()))(()) | [3, 2] [ 8] 22 | 10110 | (())()(()) | [2, 1, 2] [ 9] 32 | 100000 | (((((()))))) | [6] [10] 34 | 100010 | (((())))(()) | [4, 2] [11] 36 | 100100 | ((()))((())) | [3, 3] [12] 38 | 100110 | ((()))()(()) | [3, 1, 2] [13] 42 | 101010 | (())(())(()) | [2, 2, 2] [14] 46 | 101110 | (())()()(()) | [2, 1, 1, 2] Sequence seen as table: [0] 1; [1] 0; [2] 2; [3] 4; [4] 8, 10; [5] 16, 18, 22; [6] 32, 34, 36, 38, 42, 46; [7] 64, 66, 68, 70, 74, 76, 78, 86, 90, 94; ...
Links
- Peter Luschny, A SageMath notebook for A368279 and A369492, Jan. 2024
Programs
-
SageMath
# See the notebook in the links section, that includes a time and space efficient algorithm to generate the compositions. Alternatively, using SageMath's generator: def pr(bw, w, dw, c): print(f"{bw:3d} | {str(w).ljust(7)} | {str(dw).ljust(14)} | {c}") def Trow(n): row, count = [], 0 for c in reversed(Compositions(n)): if c == []: count = 1 pr(1, 1, "()", "[()]") elif c == [1]: pr(0, 0, ".", "[]") elif c[-1] != 1: if all(part <= c[0] for part in c): w = Words([0, 1])(c.to_code()) dw = DyckWord(sum([[1]*a + [0]*a for a in c], [])) bw = int(str(w), 2) row.append(bw) count += 1 pr(bw, w, dw, c) # print(f"For n = {n} there are {count} composition of type A369492.") return row for n in range(0, 7): Trow(n)
Comments