-2

What would be the best way to determine a set of numbers which satisfies a given hamming distance

Say I had a 5bit number and I needed to identify the numbers which have a hamming distance >= 2.

Below is how far I have gotten. What I believe I need todo is then iterate over my list against the other entries in this list to remove the <2 entries.

Finally I believe I need another outer loop going over every possible initial entry because there maybe a different "seed" which yields a larger number of entries.

#!/usr/bin/env python

TARGET=2

num = range(2**5)
results = []
for i in num:
    for j in num: # 2nd pass
        tmp = i^j
        if bin(tmp).count('1') >=2: 
            results.append(tmp)

print(set(results))
Naib
  • 999
  • 7
  • 20

1 Answers1

0

(Not Sure, just a exemple)

For 5 digits and hamming distance = 1

1)

10000
00000

OR

2)

01111
11111

but bits not equals between them , can be everywhere inside binary sequence.

So, for 1) there are 5 possibilities S={2^4 , 2^3, 2^2, 2^1, 2^0}

for 2) there are 5 possibilities too S={2^4 , 2^3, 2^2, 2^1, 2^0)

For hamming distance =2 :

1)

01111
10111

OR

2)

11000
00000

If hamming distance == n , size(number)-n bits are useless.

So, it's just combination dist_hamming of size_number

nissim abehcera
  • 821
  • 6
  • 7