I was going to check my solution to pset3 fifteen with check50 while I received two failure errors on the console (on the last 3x3 and 4x4 checks).
:) fifteen.c exists.
:) fifteen.c compiles.
:) 3x3 board: init initializes board correctly
:) 3x3 board: catches moving 8 an illegal move
:) 3x3 board: catches moving 1 as a legal move
:) 3x3 board: move blank up twice
:) 3x3 board: move blank left twice
:) 3x3 board: move blank left then right
:) 3x3 board: move blank up then down
:) 3x3 board: move up-up-left-down-down-left-up-up-right-down-down-right
:) 3x3 board: make sure none of 2, 4, 5, 6, 7, 8 move tile
:) 3x3 board: move blank left (tile 1) then up (tile 4), then try to move tiles 1, 2, 6, 8
:( 3x3 board: make sure game is winnable
expected "Tile to move:", not "\x1b[2J\x1b[0;0..."
:( 4x4 board: make sure game is winnable
timed out while waiting for program to exit
I really can't get the point of the failure. I double checked my solution and it seems to me that everything works fine.
This is the won()
code I wrote (99 is the "_" character):
bool won(void)
{
int count = 0;
int prev = 0;
int max_tile = (d * d) - 1;
for(int i = 0; i < d; i++)
{
for(int j = 0; j < d; j++)
{
if(prev < board[i][j])
{
prev = board[i][j];
count += 1;
}
}
}
if(count == max_tile -1 && board[d-1][d-1] == 99)
{
return true;
}
return false;
}
Can someone give me advice on how to fix these two errors? Thank you in advance!