0

It's still hard for me to see what I am doing wrong..

I am initializing a counter to 1.

Then inside 2 for loops (to iterate over the board), I place the next code:

        if (board[i][j] == counter)
        {
            counter++;
        }
        else if (board[i][j] == 0)
        {
            counter++;
        }

Then after closing the for-loops I check the following:

if ((d*d) == counter && board[d-1][d-1] == 0)
    return true;
else
    return false;

check50 is giving me this:

:( 3x3.txt wins the 3x3 board

\ expected an exit code of 0, not a prompt for input

:( 4x4.txt wins the 4x4 board

\ expected an exit code of 0, not a prompt for input

In what way am I asking for a prompt for input? I don't understand what is meant by this.. Can someone push me the right way?

1

What that message means is that your function is not returning true when it should. Before running check50, you should "play" the game with your program and make sure it works properly. You have the .txt files that you can pipe to make sure it works.

I'm not 100% sure, but what I'm thinking the problem may be is this: Your counter variable is initialized to 1, so that you can correctly check for it to match the values of the board. Now, after checking you increment it, so after checking board[0][0], which holds the value 1, counter becomes 2. After checking board[0][1], which holds the value 2, counter will be 3, and so on. So, what value will counter have after checking the full board, last tile included?

TILES .................................VALUE AFTER ++

1...2...3...............................2....3....4

| improve this answer | |
  • What you thought was indeed the problem with my code. Thanks a lot! – LvdD Feb 3 '16 at 9:52

You must log in to answer this question.

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