# how to fill elements of adjacents cells of a 4x4 table?

hi! we are making a 4x4 table and need to insert the data in its adjacent cell. we are able to get the adjacent cells but when we are putting the element on each cell, not all cells have content. there is only 1-3 cells with element. how can we solve this problem? thanks in advance

here is our code.

//first random position
System.Random rnd = new System.Random();
int initA = rnd.Next(1, 4);
int initB = rnd.Next(1, 4);
Debug.Log(β[β + initA + β,β + initB + β]β);

``````    // getting neighbors and adding elements
{0,-1},      {0,1},
{1,-1},{1,0},{1,1}};

int neighborRow = initA, neighborCol = initB;
for (int i = 0; i < binDigits.Length; i++)
{
int curRow = neighborRow, curCol = neighborCol;

neighborCol = neighborCol + adder[i, 1];
Debug.Log(i);

while (neighborRow < 0 || neighborCol < 0  || neighborRow >= 4 || neighborCol >= 4 || isFilled[neighborRow, neighborCol] != false)
{
int curRnd = Random.Range(0, 8);
neighborRow = curRow + adder[curRnd, 0];
neighborCol = curCol + adder[curRnd, 1];
}
Debug.Log("neighbors: [" + neighborRow + "," + neighborCol + "]");

isFilled[neighborRow, neighborCol] = true;
Debug.Log("isFilled? " + isFilled[neighborRow, neighborCol]);

tileGrid[neighborRow, neighborCol] = binDigits*.ToString();*
``````

Debug.Log(βContent{ " + tileGrid[neighborRow, neighborCol] + " }β);

}

binDigits is an array containing the elements to be put in the tileGrid. Thanks!