1. ## Minesweeper adjacent mines with one dimensional array?

So I've searched around the internet for a way to check for adjacent mines. And a lot of algorithms for it do exist out there. The thing is
that all of the solutions that I've encountered for the algorithm is using a two dimensional array while I want to use a one dimensional array.

I will create my array and initialize 10 mines at random positions. Then I want to count the mines around these squares that are initialized to 0.

So the solutions out there for two dimensional arrays work, but how would I go with a one dimensional array?

Also consider that I don't take in x and y coordinates in the function that creates the board.

So I would need some tips or refering for who to do this.

Simple Minesweeper [C] -- Kinda eh..

Implementation of Minesweeper Game - GeeksforGeeks 2. I think you should be able to copy the 2D array algorithm whole cloth if you just convert the i, j coordinates to a one dimensional subscript.

It's a simple formula i * x + j where x is the total number of columns in the "2D" array. 3. Refering to the second link inmy post.

How would I use that formula in:

Code:
```bool isMine (int row, int col, char board[][MAXSIDE])
{
if (board[row][col] == '*')
return (true);
else
return (false);
}```
Since it is no for loop inside of this function?
Should I just let the function take in the index
as parameter and calculate the index using
i * x + j as an argument like this?

Code:
```bool isMine (int index, char board[][MAXSIDE])
{
if (board[index] == '*')
return (true);
else
return (false);
}```
Calling the function:
Code:
```if (isMine (i * x + j, board)) {
// ...
} ``` 4. That wouldn't be what I would do, personally. I would pass i and j into the function and calculate i*x+j internally. This way, you can think of board the way you are using it, even though it is just a one dimensional array. Consider that if you call isMine(i*x+j, board); if you mess up the argument, the function will check the wrong cell, and it's better to codify the formula so no human can mess it up (short of simply brainfarting on i and j). Popular pages Recent additions adjacent, array, dimensional, mines, solutions 