# Pset 3, Move, What am I doing wrong?

Please give me some suggestions, I think I'm reasonably close:

``````bool move(int tile)
{
int temp;
int didSwap;
int blankRow;
int blankCol;

// search for blank tile

for(int row = 0; row < d; row++)
{
for(int col = 0; col < d; col++)
{
if(board[row][col] == 0)
{
blankRow = row;
blankCol = col;
}
}
}

// check that tile is not too big or too small

if(tile > d * d - 1 || tile < 1)
{
return false;
}

// search for blank tile

for(int row = 0; row < d; row++)
{
didSwap = 0;
for(int col = 0; col < d; col++)
{
if(tile == board[blankRow+1][blankCol] && tile != board[d+1][d])
{
temp = board[blankRow][blankCol];
board[blankRow][blankCol] = tile;
tile = temp;
didSwap = 1;
return true;
}
else if(tile == board[blankRow-1][blankCol] && tile != board[d-1][d])
{
temp = board[blankRow][blankCol];
board[blankRow][blankCol] = tile;
tile = temp;
didSwap = 1;
return true;
}
else if(tile == board[blankRow][blankCol+1] && tile != board[d][d+1])
{
temp = board[blankRow][blankCol];
board[blankRow][blankCol] = tile;
tile = temp;
didSwap = 1;
return true;
}
else if(tile == board[blankRow][blankCol-1] && tile != board[d][d+1])
{
temp = board[blankRow][blankCol];
board[blankRow][blankCol] = tile;
tile = temp;
didSwap = 1;
return true;
}
else
{
return false;
}
}
}
return false;
}
``````

I can't work out for the life of me how this is not working. Is it something to do with the swap?

``````if(tile == board[blankRow+1][blankCol] && tile != board[d+1][d])