I won't get much out of pure LaTeX just to say this. But my question is: if I have an array with 2 values in it, sorted as x[0-255],y[0-255] where I have every possible combination, 65536
How can I do this in algebra? I'm writing a computer program and I need the exact index of the two character string.
Now each value is retrievable. But I need the math to do it, instead of just searching for the optimization.
They are ordered like this:
[0,0][0,1][0,2]...[1,0][1,1][1,2]...[255,255]
Let's say you want to find the index for the pair (x, y). Then that index can be calculated by $x \cdot 256 + y$. (Note that I'm assuming that the first element has index $0$.)
For example for the pair (2, 50) the index would be 562.