Ad
  • Default User Avatar

    Thanks for your reply. And yeah, you are correct, after timing it on my machine I was surprised. It does seem strange in that it to me seems like you have to traverse the list twice with both the set() and count() operations (instead of just traversing the list once and breaking as soon as you find a unique value). Being wrong teaches you something new though :)

  • Default User Avatar

    Very neat and elegant solution indeed. A bit funny though to consider that a solution like this has most votes on "Best Practice" given that the kata description explicitly states: "... so think about performance" :)

  • Default User Avatar

    Agreed. I think it's a 7kyu without the negative/above 255 check, and with those checks a 6kyu (also for understanding hex).

  • Default User Avatar

    See my explanation above to Yedya.

  • Default User Avatar

    Think about yourself being at the supermarket where there are n self-service check-outs, and a line of customers, where you know how long time it takes for each customer. How long time does it take in total for all customers to check out? That's it.

  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

    Notwithstanding the empty array requirement, I find it interesting that this type of solution is rated lower than an O(n^2) solution, where you calculate a sum for each iteration, i.e. not making use of already used calculations. Any ideas why? Because the code is shorter simply?

  • Default User Avatar

    [-10, 10] should return -1. You start at index 0, and here the left sum is 0 and right sum is 10. Next, index is 1, and here left sum is -10 and right sum is zero. You never go to index 2 (where the left sum would equal the right sum), since index 2 is not an index in the array.

  • Default User Avatar

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

  • Default User Avatar

    Really nice kata, well done! In my humble opinion, this is a 3kyu though, quite a big harder than most 4kyu I think.

  • Default User Avatar

    My tip would be to try and google it, see what you find for other languages, and try to extrapolate to python. Try googling something along the lines of returning a function from a function.

  • Default User Avatar

    For me (as a relative novice), this problem seemed really difficult/strange to begin with. However, after understanding it better after som googling, I now think it's an extremely useful kata, and I would recommend everyone being stuck here to hang in there and try a little harder. GL :)

  • Default User Avatar

    Really nice way of using a recursive method, really smooth.