I have many pairs of numbers (A,B), with both numbers in the pair falling between 0 and N. As an example, let's say N=100.
I need a way to uniquely map these pairs to another number. We assume pairs of (A,A) or (B,B), etc are not valid pairs.
Since I don't care about the order, these are combinations. So the total number of such pairs should be N(N-1)/2. For this example, that means there are 4950 combinations.
However, if I were to use Cantor's algorithm, I would get numbers between 0 and 20,000. That's no good! It's even worse than permutations, which you could imagine as a table of N by N (100^2).
Because this is needed for programming, I need the produced integer number from the pair to be as small as possible while still remaining unique. I also ideally need the math to be fast and simple as this will be done many times.
Is there another pairing function I can use, or did I misunderstand something along the way? Forgive me, my math is rusty.