Ad
  • Custom User Avatar

    You know, I hate to say it, but after trying to paste in the tests into the sample test section, seeing them work, I thought it might be something like that.

    Thanks for your help, guys. I'll take another look at the docs!

  • Custom User Avatar

    Your code uses global vars and they keep their value between tests, that's a problam with your code, not with Codewars. Read the docs: https://docs.codewars.com/training/troubleshooting#your-solution-seems-to-work-or-is-close-to-working-but-still-fails-tests

    In this case, you keep adding elements to the array and your code only checks the first 3. So, if the first test is giving you a 0, all the other tests will give you the same result.

  • Custom User Avatar

    If codewars is the problem, how are you going to duplicate finding the correct answer by using codewars?

    The code runs fine in vs code. The test arrays I've been using have come directly from codewars' attempt to run the code. Each time, the test produces correct answers locally, in vs code, and incorrect answers on codewars. It's weird, but I have not been changing the code; I've been copying and pasting completely. So either something is working that shouldn't be in vs code, or something isn't working that should be on codewars. Or I'm missing something, completely.

    I don't see how adding a new sample test would be the solution, if I understand what you mean. It's possible I don't.

  • Default User Avatar

    I ran your code on Codewars.

    You can do exactly what I did, which was add the test you provided above to the Sample Tests. When you run the code, you will see -1 for that test.

  • Custom User Avatar

    The console log agrees with the result in both cases (on codewars and on my local computer).
    Where are you getting the -1 return?
    Have you tried running it in vs code?
    I don't see why they would not agree.

  • Default User Avatar

    For the test example you provided, your code actually returns -1.

    Furthermore, the notion that Console.log() is not functioning properly on Codewars is also extremely unlikely.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    For the following board: [[2,2,2],[0,1,1],[1,0,0]] - Expected: 2, instead got: 0

    On my local machine, when I enter the given array

    isSolved([[2,2,2],[0,1,1],[1,0,0]]);

    I receive a 2 locally, but on the site, it returns a 0. The console log is also wrong online, but correct on my machine.

    I've checked every failed test, with the same results.

  • Default User Avatar

    The odds are extremely high that your vs code has incorrect testing.

    Can you give an example?

  • Custom User Avatar

    Failures in the attempt here complete with correct results in vs code.