Any and all help appreciated. Please and thank you. :)

Here's my code: https://gist.github.com/noilddude/48e7d0f30ee5bb80d7e0f5d2490899b2

Here's what happens when I run check50: enter image description here


Simply put, the won() function doesn't work correctly. It's giving a premature win signal. As written, all it needs to see is 1 in the first box to generate a win.

If you walk through the code of your won() function, you'd see that the inner loop will only ever execute once. If 1 is not in board[0][0], it will immediately return false. The problem is that if it is 1, the code will immediately return true, without checking any other elements.

In this scenario, true should ONLY be returned after all the elements have been checked. While checking, the code should simply continue looping if all the correct numbers are in the correct array elements, and should immediately stop if something is in the wrong place. It should NOT return true until the inner and outer loops complete.

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

  • Got it! Thank you for your help! :)
    – Milad
    Apr 5 '17 at 0:01

You must log in to answer this question.

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