# How to convert a 1D array to a 2D array (indexed by 1)?

A very similar question has already been asked here. However, in the answer, the author assumed that the indexes started from 0, which is not the case of the problem I am currently working on.

So let's say you have an array of 9 elements:

`a = [1,2,3,4,5,6,7,8,9]`

and you want to flatten this vector by calculating the corresponding indices (i, j) of the table

`A = [[1,2,3], [4,5,6], [7,8,9]]`

Then, I know that, given (i, j), if we want to find the corresponding index of the vector, we have
`a[N(i-1)+j] = One[i][j]`

where i and j go from 1 to N. I want to know how to go in the other direction, that is to say the given index of the table `a`, how to find the corresponding index on the matrix `A.`

If we are given `a[k]` and we want to find `I` and `j` then we could try

`j = k% N`

and

`i = int ((k-j) / N + 1)`

The problem here is that `j` is the rest and can therefore take values ​​of `0` at `N-1`. I guess it would be nice to see a technique to change the clues.