I hope all is well.
I am blocked on the game of Fifteen section of Pset 3.
I am taking this one function at a time and I am on the move function.
I am able to find the tile that the user would like to move. However, at that point I am basically blocked on how to find the location of the desired tile in relation to the blank tile.
I know that I could potentially use an if statement with multiple conditions. With that said I am stuck because I don't know how to access that element(or in my case the element of the board array containing the int 0 contains).
The other option that I have is using a pointer, but a pointer won't do because it will only work with one element (not the whole 2D array).
Would someone be able to give me some pointers in the right direction please (without giving the game away)?
I have put my code below this message
Please reply as soon as possible.
Kind regards,
Adi Khajuria A CS50 student from London, UK
bool move(int tile)
{
for(int i = 0; i < d; i++)
{
for(int j = 0; j < d; j++)
{
if(tile == board[i][j])
{
printf("tile: %i was found. Moving it...", tile);
}
}
}
return false;
}