Ad
  • Custom User Avatar

    data structure starts here :)

  • Custom User Avatar

    no that is not your result. that's what you print. test your function from outside the function (or somehow figure out what the result is and print that)

    the sample tests show how it is called and how it is checked

  • Custom User Avatar

    My result is [5454, 1, 65, 2, 65, 4, 34, 4, 6, 5, 5, 5]. I think this is a right result! But system have writtten that is not right result! Why??? I have no idea why???

  • Custom User Avatar

    Python:

    • New test framework required
    • Sample tests border on useless
  • Custom User Avatar

    While my approach passes the standard tests it fails often in the random tests. The test suite claims that for example for the difference of
    A-B = [9, 12, 1, 1, 77, 34, 1, 1, 0, 73, 20, 25, 60, 42, 28, 24, 10, 11, 30, 35, 36, 0, 33, 18, 51, 26, 0, 51, 13, 25, 13, 10, 49, 8, 5, 25, 64, 12, 42, 1, 13, 57, 43, 0, 1, 39, 12, 10, 18, 1, 27, 1, 31, 7, 71, 61, 27, 38, 15, 42, 1, 11] the optimal solution is 21 thieves for k=77.

    As far as I can see from solving this by hand and with a binary division and greedy approach it can be achieved with 20 thieves without breaking the rules. This also corresponds to the heuristic for the lower bound of the sum(differences)/k which is 19.5. Am I missing something or are the random tests only sometimes using the optimal solution as K01egA hinted at?

  • Custom User Avatar

    This is the best solution and if you have something to tell shut up please ;)

  • Custom User Avatar

    Oh I forgot this rule. Thanks for reminding!

  • Custom User Avatar

    This was a great opportunity to come up with a creative solution!
    It’s always interesting to see how others approach the same problem after you’ve solved it.
    Thanks for this awesome kata!

  • Custom User Avatar

    very easy kata!
    Hint: Just use by simple math formula to count the odd numbers.

  • Custom User Avatar

    C++

    The resulting array shouldn't necessarily match anyone in the tests, a function just checks if the array is now wave sorted.

    The vector content should stay the same

    It can't be both together. If the function only checks if the array is wave sorted, it shouldn't check if it stays the same.

    It's even worse: i've added

    if(is_wave_sorted(v))
        return;
    

    at the beginning of my function, and still it returns "The vector content should stay the same". So, my function only runs if the check function fails - and still the vector should stay the same?

  • Custom User Avatar

    This problem can be reduced to the set cover problem, which is NP-hard, looking at size of tests I can assume that reference solution uses some king of greedy approach, which do not guaranty optimal solution.
    Example A = [3, 8, 8, 6, 7], B = [2, 2, 3, 5, 6], k = 6. My solution is 3. First thief can take from jars 1 and 4 second from 2, third from 3 and 5

  • Custom User Avatar
  • Custom User Avatar

    Merged

  • Custom User Avatar
  • Custom User Avatar
  • Loading more items...