Consider the following hash function:
The function computes a hash value of a string consisting of the characters . Each character is in the range a
–z
, and the characters have been coded so that a
is , b
is etc.. The function involves two constants with the values and .
For example, when the string is kissa
, the function evaluates to
In a file hashing.py
, implement the function hash_value
that returns the hash value of the string given as a parameter.
def hash_value(string): # TODO if __name__ == "__main__": print(hash_value("abc")) # 25 print(hash_value("kissa")) # 2905682 print(hash_value("aybabtu")) # 154753059 print(hash_value("tira")) # 235796 print(hash_value("zzzzzzzzzz")) # 2739360440