%I #28 Oct 01 2024 08:50:44
%S 0,1,0,1,1,0,0,1,2,3,1,0,0,1,0,1,1,2,2,3,3,1,1,0,0,0,0,1,1,0,0,1,2,3,
%T 1,2,4,5,2,3,6,7,3,1,2,3,1,0,0,1,0,0,0,1,0,1,2,3,1,0,0,1,0,1,1,2,2,3,
%U 3,1,1,2,2,4,4,5,5,2,2,3,3,6,6,7,7,3,3
%N In the binary expansion of n: collapse bits from most to least significant 10 -> 1, 01 -> 0, 00 -> nothing, 11 -> nothing.
%C This is essentialy the Von Neumann biased to fair coin extractor.
%C a(n) = 0 if the collapse results in no bits.
%C If the bit size of n is odd then the least significant bit is ignored.
%H Paolo Xausa, <a href="/A374849/b374849.txt">Table of n, a(n) for n = 1..10000</a>
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Fair_coin">Fair coin</a>.
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Randomness_extractor">Randomness extractor</a>.
%e For n = 27983, the bits of n collapse as
%e n = binary 11 01 10 10 10 01 11 1
%e a(n) = binary 0 1 1 1 0 = 14
%t A374849[n_] := FromDigits[StringReplace[IntegerString[n, 2], {"01"->"0", "10"->"1", Repeated[_, 2]->""}], 2];
%t Array[A374849, 100] (* _Paolo Xausa_, Oct 01 2024 *)
%o (Python)
%o def a(n):
%o e, B = "", bin(n)[2:]
%o for i in range(0,len(B),2):
%o if B[i:i+2] == "10": e += "1"
%o if B[i:i+2] == "01": e += "0"
%o if e == '': return 0
%o return int(e,2)
%o print([a(n) for n in range(1,70)])
%K nonn,base,easy
%O 1,9
%A _DarĂo Clavijo_, Sep 16 2024