Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #21 Apr 30 2020 14:53:34
%S 0,1,1,1,0,1,2,2,2,2,1,1,0,1,1,2,2,1,1,2,2,2,1,2,0,2,1,2,3,3,3,3,3,3,
%T 3,3,1,2,1,2,0,2,1,2,1,2,2,2,2,1,1,2,2,2,2,2,1,2,1,1,0,1,1,2,1,2,3,3,
%U 3,3,2,2,2,2,3,3,3,3,2,2,1,2,2,1,0,1,2,2,1,2,2,3,3,2,2,3,3,1,1,3,3,2,2,3,3
%N Table of Hamming distances between binary vectors representing i and j, for i >= 0, j >= 0, read by antidiagonals.
%C a(n,0) = a(0,n) = A000120(n).
%H Alois P. Heinz, <a href="/A101080/b101080.txt">Antidiagonals n = 0..200, flattened</a>
%F a(i,j) = A000120(A003987(i,j)).
%e a(3,5) = 2 because the binary Hamming distance (number of differing bits) between ...0011 and ...0101 is 2.
%e From _Indranil Ghosh_, Mar 31 2017: (Start)
%e Array begins:
%e 0, 1, 1, 2, 1, 2, 2, 3, ...
%e 1, 0, 2, 1, 2, 1, 3, 2, ...
%e 1, 2, 0, 1, 2, 3, 1, 2, ...
%e 2, 1, 1, 0, 3, 2, 2, 1, ...
%e 1, 2, 2, 3, 0, 1, 1, 2, ...
%e 2, 1, 3, 2, 1, 0, 2, 1, ...
%e 2, 3, 1, 2, 1, 2, 0, 1, ...
%e 3, 2, 2, 1, 2, 1, 1, 0, ...
%e ...
%e Triangle formed when the array is read by antidiagonals:
%e 0;
%e 1, 1;
%e 1, 0, 1;
%e 2, 2, 2, 2;
%e 1, 1, 0, 1, 1;
%e 2, 2, 1, 1, 2, 2;
%e 2, 1, 2, 0, 2, 1, 2;
%e 3, 3, 3, 3, 3, 3, 3, 3;
%e ...
%e (End)
%p H:= (i, j)-> add(v, v=convert(Bits[Xor](i, j), base, 2)):
%p seq(seq(H(n, d-n), n=0..d), d=0..20); # _Alois P. Heinz_, Nov 18 2015
%t a[i_, j_] := Total[IntegerDigits[BitXor[i, j], 2]]; Table[a[i-j, j], {i, 0, 20}, {j, 0, i}] // Flatten (* _Jean-François Alcover_, Apr 07 2016 *)
%o (PARI) b(n) = if(n<1, 0, b(n\2) + n%2);
%o tabl(nn) = {for(n=0, nn, for(k=0, n, print1(b(bitxor(k, n - k)),", ");); print(););};
%o tabl(20) \\ _Indranil Ghosh_, Mar 31 2017
%o (Python)
%o for n in range(20):
%o print([bin(k^(n - k))[2:].count("1") for k in range(n + 1)]) # _Indranil Ghosh_, Mar 31 2017
%Y Cf. A000120, A003987.
%K easy,nonn,tabl
%O 0,7
%A _Marc LeBrun_, Nov 29 2004