A101080 Table of Hamming distances between binary vectors representing i and j, for i >= 0, j >= 0, read by antidiagonals.
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, 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, 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
Offset: 0
Examples
a(3,5) = 2 because the binary Hamming distance (number of differing bits) between ...0011 and ...0101 is 2. From _Indranil Ghosh_, Mar 31 2017: (Start) Array begins: 0, 1, 1, 2, 1, 2, 2, 3, ... 1, 0, 2, 1, 2, 1, 3, 2, ... 1, 2, 0, 1, 2, 3, 1, 2, ... 2, 1, 1, 0, 3, 2, 2, 1, ... 1, 2, 2, 3, 0, 1, 1, 2, ... 2, 1, 3, 2, 1, 0, 2, 1, ... 2, 3, 1, 2, 1, 2, 0, 1, ... 3, 2, 2, 1, 2, 1, 1, 0, ... ... Triangle formed when the array is read by antidiagonals: 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, 3, 3; ... (End)
Links
- Alois P. Heinz, Antidiagonals n = 0..200, flattened
Programs
-
Maple
H:= (i, j)-> add(v, v=convert(Bits[Xor](i, j), base, 2)): seq(seq(H(n, d-n), n=0..d), d=0..20); # Alois P. Heinz, Nov 18 2015
-
Mathematica
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 *)
-
PARI
b(n) = if(n<1, 0, b(n\2) + n%2); tabl(nn) = {for(n=0, nn, for(k=0, n, print1(b(bitxor(k, n - k)),", ");); print(););}; tabl(20) \\ Indranil Ghosh, Mar 31 2017
-
Python
for n in range(20): print([bin(k^(n - k))[2:].count("1") for k in range(n + 1)]) # Indranil Ghosh, Mar 31 2017
Comments