%I #16 Feb 25 2019 09:32:35
%S 0,1,2,10,3,11,4,12,20,100,5,13,21,101,6,14,22,30,102,110,7,15,23,31,
%T 103,111,8,16,24,32,40,104,112,120,200,1000,9,17,25,33,41,105,113,121,
%U 201,1001,18,26,34,42,50,106,114,122,130,202,210,1002,1010,19,27
%N Nonnegative integers, sorted by increasing value of A028897(n) = Sum d[i]*2^i for n = Sum d[i]*10^i, then value of n.
%C A028897(n) is the result of using the decimal digits of n, but weighting their position as in base 2. For sake of brevity we refer to this as the b-value of n in the sequel. This idea is found on the website given in links under the name "decibinary numbers".
%C The b-values increment by 1 at indices (of "records") 1, 2, 4, 6, 10, 14, 20, 26, 36, ... Prefixing an initial 0, the gaps between these, equal to the number of occurrences of a given b-value (0, 1, 2, ...), are 1, 1, 2, 2, 4, 4, 6, 6, 10, 10, 13, 13, ... = A072170(n,10). In this sequence each of (1, 2, 4, 6, 10, 13, 18, ...) is repeated twice.
%H Robert Israel, <a href="/A322000/b322000.txt">Table of n, a(n) for n = 0..10000</a>
%H Robin C. Yu, <a href="https://www.hackerrank.com/challenges/decibinary-numbers">Decibinary Numbers</a>, on Hackerrank.com.
%e The first terms of the sequence are as follows: (b = A028897)
%e n | 0 | 1 | 2 | 10 | 3 | 11 | 4 | 12 | 20 | 100 | 5 | 13 | 21 | 101 | ...
%e ----+---+---+---+----+---+----+---+----+----+-----+---+----+----+-----+-----
%e b(n)| 0 | 1 | 2 | 2 | 3 | 3 | 4 | 4 | 4 | 4 | 5 | 5 | 5 | 5 | ...
%e For example, b(345) = 3*2^2 + 4*2 + 5 = 25.
%p N:= 30: # for all numbers with A028897(n) <= N
%p L:= {seq([i,i],i=0..9)}: Agenda:= {seq([i,i],i=1..9)}:
%p extend:= proc(p) local x; op(select(t -> t[2]<=N, [seq([10*p[1]+x, 2*p[2]+x],x=0..9)])); end proc:
%p sorter:= proc(p1,p2) if p1[2] <> p2[2] then p1[2] < p2[2] else p1[1] < p2[1] fi end proc:
%p while Agenda <> {} do
%p Agenda:= map(extend, Agenda);
%p L:= L union Agenda;
%p od:
%p L:= sort( convert(L,list),sorter):
%p map(t -> t[1], L); # _Robert Israel_, Feb 24 2019
%o (PARI) my(A028897(n)=fromdigits(digits(n),2),S=[]);for(k=1,2^10,(t=A028897(k))>9||S=setunion(S,[[t,k]]));apply(t->t[2],S)
%Y Cf. A028897, A072170 (see comments).
%K nonn,base,look
%O 0,3
%A _M. F. Hasler_, Feb 13 2019
|