Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
My main concern is with overloading the console output. It goes against the submission test guidelines.
A fair compromise would be to revert the behavior of the submission tests while still printing the visualizations for the sample tests.
Thanks!
I modified it slightly to display the tree and nuts on the ground regardless of test pass/fail. This make it same as all other translations.
Please take a look at my hacked changes (I'm not a Haskell programmer). If it seems OK, I will Approve.
Haskell translation
I see it now, will try in the future.
Thanks a lot :)
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".
Try logging the inputs:
https://ibb.co/RThfQZGL
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 returnedundefined
. There is no message when your code passes a single test like that.Nope
It returns undefined:
https://ibb.co/KxYFZycw
I do not see this happening. I can see that your current, shortened solution correctly returns
[1, 1]
for inputs(15, 15)
.The issue not with random tests, but with the fixed test called "one".
Ok, will try discord sometime in the future, thanks
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.It returns undefined even if
ownedCatAndDog(15,15)
is called. That is the issue.I specifically updated it to see the error.
Your current code errors because it returns nothing unless
ownedCatAndDog(15,15)
is called. Meaning your code always returnsundefined
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 returnundefined
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.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.
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]
.Loading more items...