def rs_hash(key): a = 378551 b = 63689 hash_value = 0 for i in range(len(key)): hash_value = hash_value * a + ord(key[i]) a = a * b return hash_value