m
lines each with an n
length ascii character string
c1c2c3c4...cn1
d1d2d3...dn2
...
z1z2...znm
The input will come from stdin
.
Here n
changes from line to line and is not provided to you.
Output: m
lines each with an integer between -k
and k
, for some k
of your choosing with k
\(\leq 2^{32}\) (you may ignore the ability to use negatives).
Constraints: Your function is a hash function. Your choice of k
can be defended to me. I encourage you to look at popular hashing techniques (here is a list on wikipedia). I am looking for a good uniform spread of the outputs (in particular the printable ascii characters). Implement the hashing yourself, don't just call someone else's hash function.
Sample instance:
Input:
CaT iN hAt
Andy
Output:
1250917240
1409313076
stdin
with the integer m
. Then m
lines of key value pairs to stdin
. Each key-value line consists of two character strings separated by four spaces (neither string contains four sequential spaces).
Then you will be given a line of three asterisks followed with a line consisting of one key character string.
NONE
.
2*k
. Discuss the cost of your implementation for large values of m
2
key1 value1
key2 value2
***
key1
value1