compsci-notes-spring-2024/notes/fund-prog-3/chapter-5/programs/num_hashing.py
2024-03-11 17:44:38 -05:00

24 lines
402 B
Python

import sys
size = int(sys.argv[-5])
num = int(sys.argv[-4])
var_1 = int(sys.argv[-3])
var_2 = int(sys.argv[-2])
i = int(sys.argv[-1])
def quadratic():
h = num % size
return (h + (var_1 * i) + (var_2 * i * i)) % size
def mod_size():
return num % size
def h2():
return var_2 - (num % var_2)
def combined():
return (mod_size() + (i * h2())) % size
func = combined
print(func())