Ad
  • Custom User Avatar

    Hey, an interesting scenario, but this should be treated the same way as any other. Let's say we have an array [-5, 10, 8, 10, 2, -3, 10]; as you can see there are 3 occurences of 10, but still the algorithm works the same way: the greatest is 10, so it goes in the middle, the next greatest is 10, so it goes on both sides, then 10 again on both sides, and after that the other numbers accordingly, resulting in [-5, -3, 2, 8, 10, 10, 10, 10, 10, 8, 2, -3, -5]. I added this to the tests for clarity nevertheless.

  • Custom User Avatar

    You're right, I ommited this in the sample tests. Already fixed that, but since sample tests are editable it's not that big of an issue.

  • Custom User Avatar

    No, the kata test cases all provide a list with exactly one duplicated element, so both start and end will have actual numerical values; to be specific - index of the first occurence of the duplicated element and the index of the second occurence of the same element. These are then used to return the expected slice of the input list.

  • Custom User Avatar

    in case of that kata, the right side of the first assignment will always return a list with two values (the input list will only have one duplicated element, so the condition arr.count(x) > 1 will be met only for two identical elements), thus the assignment start, end = [...] will assign a first value to start and second to end. The values are indices of this elements, beacuse as you can see I am using the enumerate function (for more info check the Python docs on enumerate) on the input array.

  • Custom User Avatar

    Check the sample test cases to see what is wrong. Specifically, the first test case.

  • Custom User Avatar

    Definitely, 692 was duplicated in the input list, and also the median, so it should a middle element in the output, as well as reflected on both sides of the middle element, just like Chrono79 stated.

  • Custom User Avatar

    Great, now I can work with this :D Your code is fine except for one important detail you oversaw. Think about how you remove the processed arr elements and visualize your algorithm on this example: [-3, 15, 8, -1, 7, -1] ^^ I think you will get this in no time. edit: let me know if you figured this out, I really want you to get something out of this kata!

  • Custom User Avatar

    The description was updated after adressing this suggestion to "Your function should not mutate the input array, and this will be tested". Your solution clearly mutates the input.

  • Custom User Avatar

    Again, the error message you provided is far to vague, I don't know what's wrong. Post your code (with spoiler flag), so we can look into this.

  • Custom User Avatar

    Approved, thanks.

  • Custom User Avatar

    Meh, you probably need to fork this again, because I cannot approve this automatically, there's an annoying bug on CW.

  • Custom User Avatar

    Looks good, approved. I will probably make the C part of the description a little more visible, but as for now it's cool.

  • Custom User Avatar

    Oh, and due to the specific nature of C code, maybe include some words in th description regarding the different function signature, so that people would be less confused (again, this is an entry level kata).

  • Custom User Avatar

    Looks good, but I have two issues - random tests are too random: 100 arrays with random sizes 1-1000 is not only inconsistent with the description (...[the list] will vary in size between 0 and 10000), but also smaller than the test cases in other languages. There should be at least one test with 10k size array. I know this is an easy kata, but that should be no excuse for writing exhaustive tests. Another thing is that the values in the arrays are only positive integers, which is again inconsistent with the description (The list will always consist of integers in range -1000..1000). Please, address these so I can approve your translation.

  • Custom User Avatar

    Julia translation added thanks to stellartux.

  • Loading more items...