0

If I run my program, it seems te run just fine. But when I run check50 I get this response :( init initializes 3x3 board correctly \ expected file to be of length 18, not 19 :( init initializes 4x4 board correctly \ expected file to be of length 38, not 39

What am I doing wrong, and how can I fix it?

void init(void)
{
    int tileNumber = d*d-1; // Set as highest number on the board

    for (int i = 0; i < d ; i++) // Set row
    {
        for  (int j = 0; j < d; j++) // Set collum
        {
            board [i][j] = tileNumber;
            tileNumber--;
        }

    }
    // Set blank space to 99
    board [d-1][d-1] = 99;

    //If odd number of tiles, swap the tiles containing 1 and 2

    if ((d == 4) || (d == 6) || (d ==8))
    {
        board [d-1][d-2] = 2;
        board [d-1][d-3] = 1;
    }

 blankI = d-1;
 blankJ = d-1;


}
0

check50 depends on a number of things in order to be able to work. One of those is that it outputs the contents of the board array directly to a log file to check it. When it does, among other things, it checks the length of that log file. It is expecting the blank tile to be represented by 0 in the board array - a one digit number. You have implemented code to change it to 99 - a two digit array. This is causing the log file size to be off by 1, as shown in your check50 results.

You'll need to change your code to represent the blank tile with 0 to fix this.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .