Skip to content

Instantly share code, notes, and snippets.

/fifteen.c Secret

Created Aug 10, 2016
Embed
What would you like to do?
fifteen.c - shared from CS50 IDE
int init(void)
{
// TODO
int i;
int j;
int board[DIM_MAX][DIM_MAX];
int x = d*d;
for ( i = 0; i < d; i ++)
{
for ( j = 0; j < d; j++)
{
x = x-1;
board[i][j] = x;
}
}
// Swap 2 and 1
if ((((d * d) - 1) % 2) != 0)
{
int hold = board[d-1][d-2];
board[d-1][d-2] = board[d-1][d-3];
board[d-1][d-3] = hold;
}
return board[i][j];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment