Skip to content
DeepForgeby svx
All problems
MediumAlgorithmsal-334

MurmurHash Finalizer

Problem

Apply the 32-bit finalizer mix from MurmurHash3 to the integer h and return the result.

The mix XORs the value with its own high half, multiplies by 0x85EBCA6B, XORs again with a shift of 13, multiplies by 0xC2B2AE35, and ends with another XOR shift of 16. All operations keep only the low 32 bits.

Hint

Every shift is a logical right shift, so mask back to 32 bits after the multiplies.

Test cases

case 1
in: [0]
expected: 0
case 2
in: [1]
expected: 1364076727
case 3
in: [123456789]
expected: 3126909082
case 4
in: [4294967295]
expected: 2180083513
case 5
in: [42]
expected: 142593372
Starter codePython
def murmur_finalizer(h):
    # Your code here
    pass

5 test cases · run your code against them in the editor