0

I checked it with check50 and its throwing error :

check50 2015.fall.pset3.fifteen fifteen.c
:) fifteen.c exists
:) fifteen.c compiles
:( init initializes 3x3 board correctly
\ expected file to be of length 18, not 0
:( init initializes 4x4 board correctly
\ expected file to be of length 38, not 0
:| 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

I dont know why its saying log file length is 0. What can be the silly thing which I am missing. sandbox link : https://sandbox.cs50.net/checks/82d830e0be8845d58b477a73219ba555 .

I executed below 3x3.txt file of winning move but goes in infinite loop.
./fifteen 3 < ~cs50/pset3/3x3.txt

My init() code: ` void init(void) { bx=d-1; by=d-1;

//Assumption:No two tile should have same number on it.
for(int row=0; row < d; row++){
    for(int col=0; col < d; col++){
        if(row == d-1 && col == d-1){
            board[row][col]=0;
        }
        else{                
            // printf("board[%d][%d]=",row,col);
            board[row][col] = GetInt();
        }
    }
}

}`

  • Not sure what you're doing there? You're meant to initialize the board, not take input from the user. So you shouldn't use GetInt() at all in this pset. – Irene Feb 10 '16 at 2:15
  • This code is initializing board using user input. – prashant singh Feb 10 '16 at 2:24
  • The board is supposed to be initialized using the one parameter given when the program is executed. You're not supposed to prompt the user for it. Irene is right, no GetInt()! The board is supposed to be initialized using the maximum value for the board in the upper left and counting down as you go, with the special case that reverses 1 and 2 as described in the instructions. – Cliff B Feb 10 '16 at 2:44
  • Thanks I changed it now its working with 3x3.txt and 4x4.txt both. Was trying from yesterday... :). Passed check50 also. Finally time to submit. – prashant singh Feb 10 '16 at 3:06
1

check50 is trying to output the game board to a file. If it's saying that the file size is 0, it sounds like it's failing to produce the output file. As I typed this, you added that you have an infinite loop. Well, that would explain it.

| improve this answer | |
  • I have added my init() code please verify it. – prashant singh Feb 10 '16 at 2:15
  • In ~cs50/pset3/3x3.txt file I am assuming first 8 integer are tiles and remaining integer are winning moves. Right? – prashant singh Feb 10 '16 at 2:27

You must log in to answer this question.

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