删除 test.py

This commit is contained in:
2024-12-22 01:19:55 +08:00
parent 798e299d04
commit 451ac8ec83

16
test.py
View File

@@ -1,16 +0,0 @@
def hamming_distance(hash1, hash2):
# 将哈希值转换为二进制字符串
bin1 = bin(int(hash1, 16))[2:].zfill(len(hash1) * 4) # 16进制转二进制
bin2 = bin(int(hash2, 16))[2:].zfill(len(hash2) * 4)
# 计算汉明距离
return sum(c1 != c2 for c1, c2 in zip(bin1, bin2))
# 给定的两个哈希值
hash1 = 'ffffff7060606000'
hash2 = '000034e3ffffffbf'
# 计算汉明距离
distance = hamming_distance(hash1, hash2)
print(f'汉明距离: {distance}')