cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A319419 In binary expansion of n, delete one symbol from each run. Set a(n)=-1 if the result is the empty string.

This page as a plain text file.
%I A319419 #28 Jun 01 2025 13:14:36
%S A319419 -1,-1,-1,1,0,-1,1,3,0,0,-1,1,2,1,3,7,0,0,0,1,0,-1,1,3,4,2,1,3,6,3,7,
%T A319419 15,0,0,0,1,0,0,1,3,0,0,-1,1,2,1,3,7,8,4,2,5,2,1,3,7,12,6,3,7,14,7,15,
%U A319419 31,0,0,0,1,0,0,1,3,0,0,0,1,2,1,3,7,0,0
%N A319419 In binary expansion of n, delete one symbol from each run. Set a(n)=-1 if the result is the empty string.
%C A319419 If the binary expansion of n is 1^b 0^c 1^d 0^e ..., then a(n) is the number whose binary expansion is 1^(b-1) 0^(c-1) 1^(d-1) 0^(e-1) .... Leading 0's are omitted, and if the result is the empty string, here we set a(n) = -1. See A318921 for a version which represents the empty string by 0.
%C A319419 Lenormand refers to this operation as planing ("raboter") the runs (or blocks) of the binary expansion.
%C A319419 A175046 expands the runs in a similar way, and a(A175046(n)) = A001477(n). - _Andrew Weimholt_, Sep 08 2018 (Comment copied from A318921.)
%C A319419 a(n) = -1 iff n in A000975.
%H A319419 N. J. A. Sloane, <a href="/A319419/b319419.txt">Table of n, a(n) for n = 0..16384</a>
%H A319419 Claude Lenormand, <a href="/A318921/a318921.pdf">Deux transformations sur les mots</a>, Preprint, 5 pages, Nov 17 2003. Apparently unpublished. This is a scanned copy of the version that the author sent to me in 2003.
%H A319419 N. J. A. Sloane, Coordination Sequences, Planing Numbers, and Other Recent Sequences (II), Experimental Mathematics Seminar, Rutgers University, Jan 31 2019, <a href="https://vimeo.com/314786942">Part I</a>, <a href="https://vimeo.com/314790822">Part 2</a>, <a href="https://oeis.org/A320487/a320487.pdf">Slides.</a> (Mentions this sequence)
%e A319419 n / "planed" string / a(n)
%e A319419 0 e -1 (e = empty string)
%e A319419 1 e -1
%e A319419 10 e -1
%e A319419 11 1 1
%e A319419 100 0 0
%e A319419 101 e -1
%e A319419 110 1 1
%e A319419 111 11 3
%e A319419 1000 00 0
%e A319419 1001 0 0
%e A319419 1010 e -1
%e A319419 1011 1 1
%e A319419 1100 10 2
%e A319419 1101 1 1
%e A319419 1110 11 3
%e A319419 1111 111 7
%e A319419 10000 000 0
%e A319419 ...
%p A319419 r:=proc(n) local t1, t2, L, len, i, j, k, b1;
%p A319419 if n <= 2 then return(-1); fi;
%p A319419 b1:=[]; t1:=convert(n, base, 2); L:=nops(t1); p:=1; len:=1;
%p A319419 for i from 2 to L do
%p A319419 t2:=t1[L+1-i];
%p A319419 if (t2=p) and (i<L) then len:=len+1;
%p A319419 else # run ended
%p A319419    if (i = L) and (t2=p) then len:=len+1; fi;
%p A319419    if len>1 then for j from 1 to len-1 do b1:=[op(b1), p]; od: fi;
%p A319419    p:=t2; len:=1;
%p A319419 fi;               od;
%p A319419 if nops(b1)=0 then return(-1);
%p A319419 else k:=b1[1];
%p A319419 for i from 2 to nops(b1) do k:=2*k+b1[i]; od;
%p A319419 return(k);
%p A319419 fi;
%p A319419 end;
%p A319419 [seq(r(n), n=0..120)];
%o A319419 (Python)
%o A319419 from re import split
%o A319419 def A319419(n):
%o A319419     s = ''.join(d[:-1] for d in split('(0+)|(1+)',bin(n)[2:]) if d not in {'','0','1',None})
%o A319419     return -1 if s == '' else int(s,2) # _Chai Wah Wu_, Sep 24 2018
%o A319419 (Python)
%o A319419 from itertools import groupby
%o A319419 def a(n):
%o A319419     s = "".join(k*(len(list(g))-1) for k, g in groupby(bin(n)[2:]))
%o A319419     return int(s, 2) if s != "" else -1
%o A319419 print([a(n) for n in range(82)]) # _Michael S. Branicky_, Jun 01 2025
%Y A319419 Cf. A000975, A175046, A318921.
%K A319419 sign,base,hear
%O A319419 0,8
%A A319419 _N. J. A. Sloane_, Sep 21 2018