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.
This comment is hidden because it contains spoiler information about the solution
As stated in the solution set up, you must report the size of your output to the parameter
*tree_size
before returning your answer, it is not given:This comment is hidden because it contains spoiler information about the solution
Which one is required now?
4 (2+avg 10 30) = 13.0
or(avg 4 2) + (avg 10 30) = 23.0
? Thanks really.It's not a question of view, that's how CodeWars is designed and it would be impossible in another way. That would mean to open a beta validation process for each of the more than 50 languages currently available, with reviewers for all of them. That would last ages, causing a great amount of useless duplicate work and simply wouldn't be manageable (most languages count with a small number of active users involved, and they are often the same ones across least common languages).
In all cases, kyus are shared between languages.
I see two issues:
Firstly, the code modifies the image that is passed (
globimage.pixels
points to the same place asimage.pixels
). This is going to cause problems in situations where the tests ask about multiple colours on the same image. The sample tests are such a situation; this is why the code fails the second sample test.Secondly, your algorithm is O(n^1.5), not O(n) (where n = number of pixels). Imagine what would happen if the image were a k by k square (so n=k^2) with all pixels the same colour.
Your function
insideDepthBorders
will be called k^2 times on the first iteration, then (k-1)^2 times the second iteration, then (k-2)^2 times the third iteration, etc. The total number of calls is O(k^3); that is, O(n^1.5).I didn't examine your code closely so I can't tell, but I suggest you to focus on this sample test you're failing, maybe you'll find a fail that can explain other flaws. You function
getPixels
is recursive, I'm not sure all this is linear.Your code seems to return the correct anwer (no failed test), but it's too slow (time out).
Glad you liked it, and I hope you found it challenging enough :)
Good job!
.
the expected result for this test is false, not true (I mean, that's what is written in the tests)
You're probably failing another test. I don't know what you did, but that clearly on your side.
This comment is hidden because it contains spoiler information about the solution
Aren't all of these questions answered in the description?
What language do you attempt?
It's an incorrect test structure (
@test.it
without assertions), so it doesn't fail, but isn't shown as passed.