I'm looking for the shortest equation to find the flattened position of an ordered pair.
Let's use a TicTacToe board for example.
|---|---|---|
| 0 | 1 | 2 |
|---|---|---|
| 3 | 4 | 5 |
|---|---|---|
| 6 | 7 | 8 |
|---|---|---|
Given (1, 1)
, how can I get 4
?
What about (2, 1)
to get 5
?
I would like the solution to be general and not language syntax-specific.