Given the inputs $(i,j)=(1,1),(2,1),(2,2),(3,1),(3,2),(3,3),(4,1),(4,2)... $ find a function such that $f(i,j)=1,2,3,4,5,6,7,8,...$
I have tried by trial and error for a long time and have yet to come up with an equation that $f(1,1)=1$ and $f(2,1)=2$ and $f(2,2)=3$...
Is there a non trial&error method to come up with this?
It is easy to satisfy two, but I can't get passed that.
To think this through note that it is fairly easy to compute $f(i,1)$. After all, there is one pair of the form $(1,*)$. Two pairs of the form $(2,*)$ and, generally, $k$ pairs of the form $(k,*)$. Thus $$f(i,1)=1+2+3+\dots+(i-1)+1=\frac {i(i-1)}{2}+1$$ It follows at once that $$f(i,2)=\frac {i(i-1)}{2}+2$$ and, generally, $$f(i,j)=\frac {i(i-1)}{2}+j$$