Ad
  • Custom User Avatar

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

  • Custom User Avatar

    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:

    int *tree_by_levels (const Tree *tree, size_t *tree_size)
    {
      *tree_size = 0; // report the tree size
      return NULL; // return a heap-allocated array, it will be freed
    }
    
  • Custom User Avatar

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

  • Custom User Avatar

    Which one is required now? 4 (2+avg 10 30) = 13.0 or (avg 4 2) + (avg 10 30) = 23.0? Thanks really.

  • Custom User Avatar

    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).

  • Custom User Avatar

    In all cases, kyus are shared between languages.

  • Default User Avatar

    I see two issues:

    Firstly, the code modifies the image that is passed (globimage.pixels points to the same place as image.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).

  • Custom User Avatar

    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.

  • Custom User Avatar

    Your code seems to return the correct anwer (no failed test), but it's too slow (time out).

  • Custom User Avatar

    Glad you liked it, and I hope you found it challenging enough :)

    Good job!

  • Custom User Avatar
  • Custom User Avatar

    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.

  • Default User Avatar

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

  • Custom User Avatar

    Aren't all of these questions answered in the description?
    What language do you attempt?

  • Default User Avatar

    It's an incorrect test structure (@test.it without assertions), so it doesn't fail, but isn't shown as passed.