find a unique output based on two inputs?

algorithm, c#, math, unique

Solution

Since your two numbers are less than 1000, you can do `k = (1000 * x1) + x2` to get a unique answer. The maximum value would be `999999`, which is well within the range of a 32-bit `int`.

Problem

I need to find a way, such that user has to input 2 numbers (int) and for every different value a single output (int preferably!) is returned. Say user enters `6, 8` it returns `k` when user enter anything else like `6,7` or `9,8` or any other input `m, n` except for `6, 8` (even if only one input is changed) a completely different output is produced. But the thing is, it should be unique for only that `m, n` so I cant use something like `m*n` because `6 X 4 = 24` but also, `12 X 2 = 24` so the output is not unique, so I need to find a way where for every different input, there is a totally different output that is not repeated for any other value. EDIT: In response to Nicolas: the input range can be anything but will be less then 1000 (but more then 1 of course!) EDIT 2: In response to Rawling, I can use long (Int64) but not preferably use float or doulbe, becuase this output will be used in a for loop, and float and double are terrible for for loop, you can check it here

Original source

Related problems