code: def weighted_hamming(b1, b2):
      
      assert(len(b1) == len(b2))
      hamming = 0
      for i in range(len(b1)):
          if b1[i] != b2[i]:
              # differences at more significant (leftward) bits
              # are more important
              if i > 0:
                  hamming += 1 + 1.0/i
                  # This weighting is completely arbitrary
      return hamming
docs: Hamming distance that emphasizes differences earlier in strings.