Start of main content## Recommended snippets

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()`

of`str`

class to count and return the number of`1`

s in it.

```
def hamming_distance(a, b):
return bin(a ^ b).count('1')
```

`hamming_distance(2, 3) # 1`

### Integer to roman numeral

Python, Math

Converts an integer to its roman numeral representation. Accepts value between

`1`

and`3999`

(both inclusive).### Mapped list average

Python, Math

Calculates the average of a list, after mapping each element to a value using the provided function.

### Sum list based on function

Python, Math

Calculates the sum of a list, after mapping each element to a value using the provided function.