Ad
  • Custom User Avatar

    Otherwise good solution

    ?? LOL

    Doesn't work. Fatal flaw. Otherwise good solution.

  • Custom User Avatar

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

  • Default User Avatar

    Will fail if array[0] == array[1] and the array is sorted ascending (array[i]<=array[i+1]).
    Otherwise good solution.

  • Default User Avatar

    I've added a small fix, random array will now always be of odd length.
    As the great Justin Bieber said - Sorry!
    Thanks for the feedback!

  • Custom User Avatar

    In C variant I was still getting even-length arrays, so I decided to handle that and compute median as it should be computed -- mean of 2 middle elements.
    So I spent few hours after that trying to figure out error, then I decided to handle even-length arrays as odd-length, and all tests passed.
    You should either fix description and tests, or just fix tests to generate only odd-length arrays.
    The most simple thing you should do is add while loop in int getRandomInteger(int lowerBoundInclusive, int upperBoundExclusive), checking for even value.

    P.S. Didn't mark this as spoiler since kata for C is broken and people can actually spend quite a lot time figuring out problem that doesn't exist.