Coders Packet

Finding The Hamming Distance In Python

By Rajitha Gondipalli

In this Python project , we will determine the hamming distance of two decimal numbers(by converting them into equivalent binary numbers)

Hamming Distance:

    Hamming Distance between two binary numbers is nothing but the total number of bits they differ. Let us look into few examples to understand this concept.

Examples:

Decimal number     Binary Equivalent

     9                           1001

    14                          1110

Hamming Distance(9,14) =3

In the above binary representation of 9 and 4 , we can observe that they differ by three bits hence hamming distance is 3.

Decimal number     Binary Equivalent

     25                          11001

     31                          11111

Hamming Distance(25,31) =2

In the above binary representation of 25 and 31, we can observe that they differ by two bits hence hamming distance is 2.

 

 

Download project

Reviews Report

Submitted by Rajitha Gondipalli (Rajitha)

Download packets of source code on Coders Packet