P
P
Pavel K2015-06-04 04:41:01
Qt
Pavel K, 2015-06-04 04:41:01

How to compose a hash function according to interesting conditions?

Greetings!
In general, it is required to compose a hash function,
more precisely, a function that would return the same integer value under the following criteria:
two integer numbers are input, they are always unique but can be equal to each other,
for example f(2,2) = 8865, f( 6.9) = 2341413 and so on,
I would like that when the first number is passed to the function, for example -1 (or any other negative value, or 0), and the second is 2, then the function would give 8865 (from the example above)
or vice versa, when the first number is 2, the second is -1, then the function would give the same 8865
i.e.
f(6,9) = 2341413
f(-1,9) = 2341413
f(6,-1) = 2341413
Numbers can be any positive integers, but no number can be unused.
Tell me how you can implement it without using additional lists and so on to store values, i.e. I operate with mathematical operations (degrees, roots, factorials, whatever)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
bobrovskyserg, 2015-06-04
@bobrovskyserg

If the order is not important, the pair should be ordered.
If the hash function always returns 8865 if there is a two in the pair, then it is necessary to sort by the sign "important-not important", for example, two is important, more important than -1, and build a hash by two. So to do with non-positive pairs to the deuce, but with others?
It is impossible to advance further - no other conditions are imposed, except for "it is impossible for any number to be unused".
Try to reformulate the problem.

A
Andrew, 2015-06-04
@OLS

According to your condition:
f(6,9) = 2341413, so f(6,-1) = 2341413
but
f(6,3) = 83746836, then f(6,-1) = 83746836 A
contradiction in the condition - such a function is unrealizable

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question