Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
added 404 characters in body
Source Link

Source code for init:

void init(void)
{
 int k=(d*d)-1;

for(int row=0; row<d; row++){
    for(int col=0; col<d; col++){
        board[row][col]=k; 
        if((d%2==0)&&(k==3)){
            k=1;
        }
        else if((d%2==0)&&(k==1)){
            k=2;
            
        }
        else{k--;}
    }
}
}

Error only in expected "0" character 7 of line 4, not "1" :( init initializes 4x4 board correctly )

I put a check in the draw() function.

void draw(void)
{
blank =0;
for(int i=0; i<d; i++){
    for(int j=0; j<d; j++){
        if((i==c)&&(j==r)){
            printf("%2i ", blank);
        }
        else{
                
            printf("%2i ", board[i][j]);
            
        }
    }
printf("\n");
}
}

Source code for init:

void init(void)
{
 int k=(d*d)-1;

for(int row=0; row<d; row++){
    for(int col=0; col<d; col++){
        board[row][col]=k; 
        if((d%2==0)&&(k==3)){
            k=1;
        }
        else if((d%2==0)&&(k==1)){
            k=2;
            
        }
        else{k--;}
    }
}
}

Error only in expected "0" character 7 of line 4, not "1" :( init initializes 4x4 board correctly )

Source code for init:

void init(void)
{
 int k=(d*d)-1;

for(int row=0; row<d; row++){
    for(int col=0; col<d; col++){
        board[row][col]=k; 
        if((d%2==0)&&(k==3)){
            k=1;
        }
        else if((d%2==0)&&(k==1)){
            k=2;
            
        }
        else{k--;}
    }
}
}

Error only in expected "0" character 7 of line 4, not "1" :( init initializes 4x4 board correctly )

I put a check in the draw() function.

void draw(void)
{
blank =0;
for(int i=0; i<d; i++){
    for(int j=0; j<d; j++){
        if((i==c)&&(j==r)){
            printf("%2i ", blank);
        }
        else{
                
            printf("%2i ", board[i][j]);
            
        }
    }
printf("\n");
}
}
Source Link

Everything's working in manual testing, but cs50 says 4x4 not working (pset3 fifteen)

Source code for init:

void init(void)
{
 int k=(d*d)-1;

for(int row=0; row<d; row++){
    for(int col=0; col<d; col++){
        board[row][col]=k; 
        if((d%2==0)&&(k==3)){
            k=1;
        }
        else if((d%2==0)&&(k==1)){
            k=2;
            
        }
        else{k--;}
    }
}
}

Error only in expected "0" character 7 of line 4, not "1" :( init initializes 4x4 board correctly )