Hamming distance
Calculates the Hamming distance between two values.
- Use the XOR operator (
^) to find the bit difference between the two numbers. - Use
bin()to convert the result to a binary string. - Convert the string to a list and use
count()ofstrclass to count and return the number of1s in it.