%I #53 Jan 05 2022 00:58:34
%S 0,1,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,1,0,0,1,1,1,0,0,1,0,1,1,1,0,1,1,1,
%T 0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,1,0,1,0,0,0,1,0,1,0,1,1,0,0,1,1,1,1,0,
%U 0,0,1,0,0,1,1,0,1,0,1,0,1,1,1,1,0,0,1,1,0,1,1,1,1,0,1,1,1,1,0,0,0,0,0,0,0
%N The binary Champernowne sequence: concatenate binary vectors of lengths 1, 2, 3, ... in numerical order.
%C Can also be seen as triangle where row n contains all binary vectors of length n+1. - _Reinhard Zumkeller_, Aug 18 2015
%C From _Clark Kimberling_, Jul 18 2021: (Start)
%C In the following list, W represents the sequence of words w(n) represented by A076478. The list includes five partitions and two self-inverse permutations of the positive integers.
%C length of w(n): A000523
%C positions in W of words w(n) such that # 0's = # 1's: A258410;
%C positions in W of words w(n) such that # 0's < # 1's: A346299;
%C positions in W of words w(n) such that # 0's > # 1's: A346300;
%C positions in W of words w(n) that end with 0: A005498;
%C positions in W of words w(n) that end with 1: A005843;
%C positions in W of words w(n) such that first digit = last digit: A346301;
%C positions in W of words w(n) such that first digit != last digit: A346302;
%C positions in W of words w(n) such that 1st digit = 0 and last digit 0: A171757;
%C positions in W of words w(n) such that 1st digit = 0 and last digit 1: A346303;
%C positions in W of words w(n) such that 1st digit = 1 and last digit 0: A346304;
%C positions in W of words w(n) such that 1st digit = 1 and last digit 1: A346305;
%C position in W of n-th positive integer (base 2): A206332;
%C positions in W of binary complement of w(n): A346306;
%C sum of digits in w(n): A048881;
%C number of runs in w(n): A346307;
%C positions in W of palindromes: A346308;
%C positions in W of words such that #0's - #1's is odd: A346309;
%C positions in W of words such that #0's - #1's is even: A346310;
%C positions in W of the reversal of the n-th word in W: A081241. (End)
%D Bodil Branner, Dynamics, Chap. IV.14 of The Princeton Companion to Mathematics, ed. T. Gowers, p. 499.
%D K. Dajani and C. Kraaikamp, Ergodic Theory of Numbers, Math. Assoc. America, 2002, p. 72.
%H Reinhard Zumkeller, <a href="/A076478/b076478.txt">Table of n, a(n) for n = 0..10000</a>
%H Michael Barnsley and Andrew Vince, <a href="http://www.jstor.org/stable/10.4169/amer.math.monthly.124.10.905">Self-similar polygonal tiling</a>, The American Mathematical Monthly 124.10 (2017): 905-921. See page 917.
%H Igor Pak, <a href="https://arxiv.org/abs/1803.06636">Complexity problems in enumerative combinatorics</a>, arXiv:1803.06636 [math.CO], 2018.
%F To get the m-th binary vector, write m+1 in base 2 and remove the initial 1. - _Clark Kimberling_, Feb 07 2010
%e 0,
%e 1,
%e 0,0,
%e 0,1,
%e 1,0,
%e 1,1,
%e 0,0,0,
%e 0,0,1,
%e 0,1,0,
%e 0,1,1,
%e 1,0,0,
%e 1,0,1,
%e ...
%t d[n_] := Rest@IntegerDigits[n + 1, 2] + 1; -1 + Flatten[Array[d, 50]] (* _Clark Kimberling_, Feb 07 2012 *)
%t z = 1000;
%t t1 = Table[Tuples[{0, 1}, n], {n, 1, 10}];
%t "All binary words, lexicographic order:"
%t tt = Flatten[t1, 1]; (* all binary words, lexicographic order *)
%t "All binary words, flattened:"
%t Flatten[tt];
%t w[n_] := tt[[n]];
%t "List tt of all binary words:"
%t tt = Table[w[n], {n, 1, z}]; (* all the binary words *)
%t u1 = Flatten[tt]; (* words, concatenated, A076478, binary Champernowne sequence *)
%t u2 = Map[Length, tt];
%t "Positions of 0^n:"
%t Flatten[Position[Map[Union, tt], {0}]]
%t "Positions of 1^n:"
%t Flatten[Position[Map[Union, tt], {1}]]
%t "Positions of words in which #0's = #1's:" (* A258410 *)
%t "This and the next two sequences partition N."
%t u3 = Select[Range[Length[tt]], Count[tt[[#]], 0] == Count[tt[[#]], 1] &]
%t "Positions of words in which #0's < #1's:" (* A346299 *)
%t u4 = Select[Range[Length[tt]], Count[tt[[#]], 0] < Count[tt[[#]], 1] &]
%t "Positions of words in which #0's > #1's:" (* A346300 *)
%t u5 = Select[Range[Length[tt]], Count[tt[[#]], 0] > Count[tt[[#]], 1] &]
%t "Positions of words ending with 0:" (* A005498 *)
%t u6 = Select[Range[Length[tt]], Last[tt[[#]]] == 0 &]
%t "Positions of words ending with 1:" (* A005843 *)
%t u7 = Select[Range[Length[tt]], Last[tt[[#]]] == 1 &]
%t "Positions of words starting and ending with same digit:" (* A346301 *)
%t u8 = Select[Range[Length[tt]], First[tt[[#]]] == Last[tt[[#]]] &]
%t "Positions of words starting and ending with opposite digits:" (* A346302 *)
%t u9 = Select[Range[Length[tt]], First[tt[[#]]] != Last[tt[[#]]] &]
%t "Positions of words starting with 0 and ending with 0:" (* A346303 *)
%t "This and the next three sequences partition N."
%t u10 = Select[Range[Length[tt]], First[tt[[#]]] == 0 && Last[tt[[#]]] == 0 &]
%t "Positions of words starting with 0 and ending with 1:" (* A171757 *)
%t u11 = Select[Range[Length[tt]], First[tt[[#]]] == 0 && Last[tt[[#]]] == 1 &]
%t "Positions of words starting with 1 and ending with 0:" (* A346304 *)
%t u12 = Select[Range[Length[tt]], First[tt[[#]]] == 1 && Last[tt[[#]]] == 0 &]
%t "Positions of words starting with 1 and ending with 1:" (* A346305 *)
%t u13 = Select[Range[Length[tt]], First[tt[[#]]] == 1 && Last[tt[[#]]] == 1 &]
%t "Position of n-th positive integer (base 2) in tt:"
%t d[n_] := If[First[w[n]] == 1, FromDigits[w[n], 2]];
%t u14 = Flatten[Table[Position[Table[d[n], {n, 1, 200}], n], {n, 1, 200}]] (* A206332 *)
%t "Position of binary complement of w(n):"
%t u15 = comp = Flatten[Table[Position[tt, 1 - w[n]], {n, 1, 50}]] (* A346306 *)
%t "Sum of digits of w(n):"
%t u16 = Table[Total[w[n]], {n, 1, 100}] (* A048881 *)
%t "Number of runs in w(n):"
%t u17 = Map[Length, Table[Map[Length, Split[w[n]]], {n, 1, 100}]] (* A346307 *)
%t "Palindromes:"
%t Select[tt, # == Reverse[#] &]
%t "Positions of palindromes:"
%t u18 = Select[Range[Length[tt]], tt[[#]] == Reverse[tt[[#]]] &] (* A346308 *)
%t "Positions of words in which #0's - #1's is odd:"
%t u19 = Select[Range[Length[tt]], OddQ[Count[w[#], 0] - Count[w[#], 1]] &] (* A346309 *)
%t "Positions of words in which #0's - #1's is even:"
%t u20 = Select[Range[Length[tt]], EvenQ[Count[w[#], 0] - Count[w[#], 1]] &] (* A346310 *)
%t "Position of the reversal of the n-th word:" (* A081241 *)
%t u21 = Flatten[Table[Position[tt, Reverse[w[n]]], {n, 1, 150}]]
%t (* _Clark Kimberling_, Jul 18 2011 *)
%o (PARI) {m=5; for(d=1,m, for(k=0,2^d-1,v=binary(k); while(matsize(v)[2]<d,v=concat(0,v)); for(j=1,matsize(v)[2],print1(v[j],","))))}
%o (Haskell)
%o import Data.List (unfoldr)
%o a076478 n = a076478_list !! n
%o a076478_list = concat $ tail $ map (tail . reverse . unfoldr
%o (\x -> if x == 0 then Nothing else Just $ swap $ divMod x 2 )) [1..]
%o -- _Reinhard Zumkeller_, Feb 08 2012
%o (Haskell)
%o a076478_row n = a076478_tabf !! n :: [[Int]]
%o a076478_tabf = tail $ iterate (\bs -> map (0 :) bs ++ map (1 :) bs) [[]]
%o a076478_list' = concat $ concat a076478_tabf
%o -- _Reinhard Zumkeller_, Aug 18 2015
%o (Python)
%o from itertools import count, product
%o def agen():
%o for digits in count(1):
%o for b in product([0, 1], repeat=digits):
%o yield from b
%o g = agen()
%o print([next(g) for n in range(105)]) # _Michael S. Branicky_, Jul 18 2021
%Y Cf. A007931, A030308, A053645.
%Y Cf. A341256, A341258, A341334, A342753, A342910.
%K nonn,easy,tabf
%O 0,1
%A _N. J. A. Sloane_, Nov 10 2002
%E Extended by _Klaus Brockhaus_, Nov 11 2002