functions.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:scene_detection 作者: VieVie31 项目源码 文件源码
def hamming(a, b):
    """Compute the hamming distance between 2 int.

    :param a: a 64 bits integer
    :param b: a 64 bits integer

    :type a: int
    :type b: int

    :return: the hamming distance between a, b
    :rtype: int
    """
    a = bin(a)[2:][::-1]
    b = bin(b)[2:][::-1]
    it = itertools.zip_longest(a, b, fillvalue='0')
    return sum([va != vb for (va, vb) in it])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号