login
Irregular triangle {A(n, k)} read by rows, giving in row n the numbers 1, 2, ..., 2^n - 1 ordered according to increasing binary weights, and for like weights decreasing.
3

%I #27 Dec 20 2023 07:41:21

%S 1,2,1,3,4,2,1,6,5,3,7,8,4,2,1,12,10,9,6,5,3,14,13,11,7,15,16,8,4,2,1,

%T 24,20,18,17,12,10,9,6,5,3,28,26,25,22,21,19,14,13,11,7,30,29,27,23,

%U 15,31,32,16,8,4,2,1,48,40,36,34,33,24,20,18,17,12,10,9,6,5,3,56,52,50,49,44,42,41,38,37,35,28,26,25,22,21,19,14,13,11,7,60,58,57,54,53,51,46,45,43,39,30,29,27,23,15,62,61,59,55,47,31,63

%N Irregular triangle {A(n, k)} read by rows, giving in row n the numbers 1, 2, ..., 2^n - 1 ordered according to increasing binary weights, and for like weights decreasing.

%C The length of row n is 2^n - 1 = A000225(n).

%C Also irregular triangle {A(n, k)} read by rows, giving in row n the numbers with a binary encoding of the list choose([n], m) = choose({1, 2,..., n}, m) (each encoding of length n), for n >= 1 and m = 1, 2, ..., n; written as entries for k = 1, 2, ..., 2^n - 1.

%C The binary encoding is obtained by setting 1s at the positions given by the choose([n],m) list of lists (in lexicographic order) and 0 otherwise. E.g., choose([3], 2) = [[1, 2], [1, 3], [2, 3]] with the encodings of length 3 [[1, 1, 0], [1, 0, 1], [0, 1, 1]], read as base 2 lists giving the numbers [6, 5, 3].

%C For the triangle T(n,m) of the sums of like m entries see A134346, (using offset 1).

%C The sum of row n gives A006516(n) = A171476(n-1), for n >= 1 (see A134346).

%H Paolo Xausa, <a href="/A356028/b356028.txt">Table of n, a(n) for n = 1..8178</a> (rows 1..12 of the triangle, flattened).

%e The irregular triangle A begins (commas separate the n subsequences for m = 1, 2, ..., n, corresponding to the binary encoded choose(n, m) lists or binary weights m):

%e n\k 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...

%e 1: 1

%e 2: 2 1, 3

%e 3: 4 2 1, 6 5 3, 7

%e 4: 8 4 2 1, 12 10 9 6 5 3, 14 13 11 7, 15

%e ...

%e n = 5: [16 8 4 2 1, 24 20 18 17 12 10 9 6 5 3, 28 26 25 22 21 19 14 13 11 7, 30 29 27 23 15, 31];

%e n = 6: [32 16 8 4 2 1, 48 40 36 34 33 24 20 18 17 12 10 9 6 5 3, 56 52 50 49 44 42 41 38 37 35 28 26 25 22 21 19 14 13 11 7, 60 58 57 54 53 51 46 45 43 39 30 29 27 23 15, 62 61 59 55 47 31, 63);

%e ...

%e A(4, 2) gives the number with the binary representation of the choose([4], 2) list [[1,1,0,0], [1,0,1,0], [1,0,0,1], [0,1,1,0], [0,1,0,1], [0,0,1,1]], obtained from the list choose([4], 2) = [[1,2], [1,3], [1,4], [2,3], [2,4], [3,4]], that is [12, 10, 9, 6, 5, 3].

%e A(4, 2) from the numbers 1, 2, ..., 15 with binary weight 2, that is of 3, 5, 6, 9, 10, 12, in decreasing order: 12, 10, 9, 6, 5, 3.

%t A356028row[n_]:=SortBy[Range[2^n-1],{DigitCount[#,2,1]&,-#&}];

%t Array[A356028row,6] (* _Paolo Xausa_, Dec 20 2023 *)

%o (PARI) cmph(x, y) = my(d=hammingweight(x)-hammingweight(y)); if (d, d, y-x);

%o row(n) = my(v=[1..2^n-1]); vecsort(v, cmph); \\ _Michel Marcus_, Sep 16 2023

%Y Cf. A000225, A006516, A134346, A171476, A262881, A294648.

%K nonn,tabf,base,look,easy

%O 1,2

%A _Wolfdieter Lang_, Jul 27 2022

%E Name suggested by _Kevin Ryde_.