0

My code runs fine, but check50 gives this error:

:) fifteen.c exists

:) fifteen.c compiles

:( init initializes 3x3 board correctly

   \ expected file to be of length 18, not 27

:( init initializes 4x4 board correctly

   \ expected file to be of length 38, not 48

:| 3x3 board, move blank up twice

   \ can't check until a frown turns upside down

:| 3x3 board, move blank left twice

   \ can't check until a frown turns upside down

:| 3x3 board, move blank left then right

   \ can't check until a frown turns upside down

:| 3x3 board, move blank up then down

   \ can't check until a frown turns upside down

:| 3x3 board, move up-up-left-down-down-left-up-up-right-down-down-right

   \ can't check until a frown turns upside down

:| 3x3 board, from start try to move tile 2, 4, 5, 6, 7, 8

   \ can't check until a frown turns upside down

:| 3x3 board, move blank left (tile 1) then up (tile 4), then try to move tiles 1, 2, 6, 8

   \ can't check until a frown turns upside down

:| 3x3 board, move blank up (tile 3), then try tile 2

   \ can't check until a frown turns upside down

:| 3x3.txt wins the 3x3 board

   \ can't check until a frown turns upside down

:| 4x4.txt wins the 4x4 board

   \ can't check until a frown turns upside down

My init function is as follows:

int k = d*d - 1;

for(int i=0; i<d; i++)

{
    for(int j=0; j<d; j++)
    {
       board[i][j] = k--;

    }
}
board[d-1][d-1] = 99;

if(d%2 == 0)
{
    int temp = board[d-1][d-2];
    board[d-1][d-2] = board[d-1][d-3];
    board[d-1][d-3] = temp;
}

Here is my log file the first time:

8 |7 |6

5 |4 |3

2 |1 |0

(ignore the spaces within lines)

What should i change and what does that error mean?? Thanks :)

1

This problem usually occurs for one of two reasons. It looks like you've hit both.

The check50 program looks at the log file generated in main(), not the actual screen output to check the program. (Take a look at the source code for main. ) It makes a first check by looking at the file size to see that it is correct. The designers expected 0 (a single digit) to be used for the blank tile, not 99 ( a two-digit number) which you did. Also, there was a change in the source code provided for the pset and in check50 between 2014 and 2015 that substantially changed the file size.

Is it possible that you are using last year's pset download? If so, this will fail when check50 runs. You should download the current year's pset3 file specified in the instructions.

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

5
  • I tried both the things you said.but it dint work. I am pretty sure I updated it using the update50 command as per the instructions. And I also tried plugging in 0 in place of 99.. Same error.
    – Kshitij
    Jun 12 '16 at 23:54
  • Not sure if you thought that running update50 would get you the right code for the pset, or if that was an additiona thing you did (always good though), but it doesn't get you the current pset source code to start with. You would need to download it from the current year's website, not from a previous year's site (which I just remembered was two years ago.) Next option is to edit the question and add your code for review. BTW, you didn't alter main(), did you? (continued....)
    – Cliff B
    Jun 13 '16 at 0:03
  • Also, please start your program, and when the board has been initialized and displayed for the first time, grab the contents of the log file and paste into the question as an edit.
    – Cliff B
    Jun 13 '16 at 0:05
  • Dint exactly understand the thing you mentioned about editing the question.. And I just added my log file :)
    – Kshitij
    Jun 13 '16 at 10:11
  • this worked for me. I used zero for blank tile. Sep 17 '16 at 17:42

You must log in to answer this question.

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