You are given a hash table size . Your task is to find two strings that are assigned to the same location in the hash table using the Python hash function.
In other words, find two strings x
and y
such that hash(x) % N == hash(y) % N
.
You may assume that is at most . Your solution should be efficient for this case.
In a file samehash.py
, implement a function find
that returns the two strings as a pair.
def find(N): # TODO if __name__ == "__main__": print(find(42)) # esim. ('abc', 'aybabtu')
Notice that the function hash
changes each time the Python interpreter is started. This means that the function must return different strings at different executions.