How can I convert a 1D index in the lower-left triangle of a grid into a row and column?
For example, consider this table of 1D indices, indexed by row and column
// 0 1 2 3 4
// +--------------- ...
// 0 | 0
// 1 | 1 2
// 2 | 3 4 5
// 3 | 6 7 8 9
// 4 | 10 11 12 13 14
// ...
Computing the 1D index from row and column is easy.
Computing the column from the row and 1D index would also be easy. The triangle above a row has -- with 0-based indices -- (row^2 + row)/2 indices.
How can I compute the row from the 1D index quickly, ideally in constant time, without any pre-computed mapping?