Easily computable function that is one-to-one and onto with 2 or more inputs

127 Views Asked by At

I am looking for a function that will take take n inputs and have 1 output, and knowing the 1 output and function you can get back the n inputs, without error and computationally easy in both directions.

For example, the smallest natural number solution to a linear diophantine equation.

ax + by = c

Where x and y are some numbers, likes just say 3 and 5.

304923049049*3 + 2049823483230*5 = 11163886563297

Now given 11163886563297, we can solve

a*3 + b*5 = 11163886563297

This has infinite many solutions to it, but only 1 of them is "smallest". My limited understanding is that finding the smallest solution to a linear diophantine equation is not computationally easy, and has to be done by bruteforce. ( I also think the smallest solution is not even the numbers I picked, bad example but I think you get the point)

My hope is that the function is super fast to calculate both way computationally, and allow for many inputs. Like 100 inputs and get 1 output and from the 1 output get back the 100 inputs.

I understand it probably doesn't exist, but I am looking for good candidates, even some which seem to be the case but havent been proven they are accurate or inaccurate.

1

There are 1 best solutions below

0
On BEST ANSWER

This question is very related to: https://stackoverflow.com/questions/919612/mapping-two-integers-to-one-in-a-unique-and-deterministic-way

In which @nawfal posts this link: http://szudzik.com/ElegantPairing.pdf which the pairing function is as space-efficient as possible .