login
A091444
Concatenate binary vectors ordered first by length, then by the number of 1's and finally lexicographically.
5
0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1
OFFSET
0,1
LINKS
MATHEMATICA
c[n_, k_] := If[k == 0, {0}, If[k == n, {2^n - 1}, Join[c[n - 1, k], c[n - 1, k - 1] + 2^(n - 1)]]];
b[n_] := If[n == 1, {0, 1}, Flatten[Table[c[n, k], {k, 0, n}]]];
a[n_] := Map[PadLeft, IntegerDigits[Array[b, n], 2]];
a[4] // Flatten (* Robert P. P. McKone, Aug 13 2021 *)
PROG
(Python)
from itertools import product
def sortby(x): return (len(x), x.count(1), x)
def agen(maxvecdigits):
for i in range(1, maxvecdigits+1):
for t in sorted([p for p in product([0, 1], repeat=i)], key=sortby):
yield from t
print([an for an in agen(4)]) # Michael S. Branicky, Aug 13 2021
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Paul Boddington, Jan 10 2004
STATUS
approved