I need a hash function to take a sequence of decimal numbers and return a decimal number as hash value.
>> def my_simple_hash(*args):
return reduce(lambda x1, x2: 2*x1 + x2, args)
[14, 15, 18, 21, 21, 23]
If you just want to hash a number sequence you can do
def my_hash(*args): return hash(args)
which returns the hash (for the current run of the program) of the args-tuple (
hash is fast and well tested for builtin-types) - but this is still most often a large number.
For getting a smaller value you can take the modulo like
def my_hash(*args): return hash(args)%10 # or whatever number you like
Actually you could also use
def my_hash(*args): return sum(args)%10 # or whatever number you like
which doesnt change between runs of the program but
sum does not distribute the results evenly at all.
Warning: These are not cryptographical hashes