Ad
  • Custom User Avatar

    I see it now, will try in the future.
    Thanks a lot :)

  • Custom User Avatar

    You read the test results wrong. Which I do not blame you, because it is a poor test output with not very clear feedback on failure. But the issue is not "tests expect wrong answers", but "tests use poor assertion messages".

  • Custom User Avatar
  • Custom User Avatar

    The issue not with random tests, but with the fixed test called "one".

    There is more than one test in "one". The first one is (15, 15), which your hardcoded solution passes. Then your solution fails for the second test in that block which tests (18, 21) when it returned undefined. There is no message when your code passes a single test like that.

  • Custom User Avatar
  • Custom User Avatar

    It returns undefined even if ownedCatAndDog(15,15) is called.

    I do not see this happening. I can see that your current, shortened solution correctly returns [1, 1] for inputs (15, 15).

  • Custom User Avatar

    The issue not with random tests, but with the fixed test called "one".
    Ok, will try discord sometime in the future, thanks

  • Custom User Avatar

    Once again, without seeing your exact code it is impossible to understand your problem, and fix the kata (if there is anything to fix). Saying what you did will not help, because the important part is to know how you did it. Hardcoding will be not really helpful, because with random tests it is difficult to do and requires hardcoding a lot of inputs, which I am not sure you did. There has to be some misunderstanding somewhere: either you misunderstood the task, or you misunderstood the test output, or I misunderstood your problem, because from all I see, your solution is just buggy and does not account for all cases.

    Maybe it will be easier if you come to the #help-solve channel of Codewars Discord so we could discuss the matter there.

  • Custom User Avatar

    It returns undefined even if ownedCatAndDog(15,15) is called. That is the issue.
    I specifically updated it to see the error.

  • Custom User Avatar

    Your current code errors because it returns nothing unless ownedCatAndDog(15,15) is called. Meaning your code always returns undefined in all other cases. Once your code fails the first test in a block, no other tests in the block are run. It is very unlikely that the first random test will test for (15, 15), so your code will always return undefined unless you happen to get very lucky. There is nothing wrong with the tests, I have just solved the kata in JS. There is a deprecation warning because the test framework needs to be updated, but that has no bearing on the success of your code.

  • Custom User Avatar

    I tried bunch of stuff, including straight up if else statements (latest one, yes).
    You can simply try catching (15, 15) without any other particular logic/variables/etc (that's what i call hardcoding) and it will return an error.

  • Custom User Avatar

    I am not sure what you mean by "hardcoded solutions".
    It is difficult to tell what is wrong with your code without knowing your code.

    I can see one of your solutions, but I do not know if it's the most recent one. The solution I can see returns wrong answer for, for example, ownedCatAndDog(16,16) - the expected answer is [1,1], but your solution returns [0,0].

  • Custom User Avatar

    @hobovsky
    I am afraid that's incorrect.
    Console.log and test cases provide different results, so there is no way to debug the issue.
    And as I said, even hardcoded solutions return this particular issue.

  • Custom User Avatar

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

  • Custom User Avatar

    Even if you hardcode everything, you will still get an error in JS's test cases:

    one
    expected [ +0, 1 ] to deeply equal [ 1, 1 ]
    
  • Loading more items...