Ad
  • Default User Avatar

    I literally made sure, that it does check for multiple values in a really efficient manner, then realized it's only for 2 values in total.
    Wish I realized earlier...

  • Custom User Avatar

    Take a pen and a paper and try to figure out what's going on. The code is right, at some point you're missing something.

  • Default User Avatar

    But what happens if n[0] is repeated again in n[3]? This could wouldn't run further after it encouters the "return" statement right?

  • Default User Avatar

    It seems to me that this solution is incorrect, since it assumes that the unique element is positioned at index 0 of arr?

  • Default User Avatar
  • Default User Avatar

    I guess that settles this issue...

  • Custom User Avatar

    Oh I misread your comment actually. I cannot have a well founded opinion about the issue raised since I have not solved the kata.

  • Default User Avatar

    Yes, I understand your comment, but this evidently does not apply here, because old solutions still pass in all language versions. An they pass by a wide margin. Less than 9000ms is well below th cut-off

  • Custom User Avatar

    I haven't solved the kata so I cannot say much. This is a recurring problem with performance katas, they can be closely dependent on the language version and any update can mess it up. This is not fair however, and ideally the tests should be adjusted when a new update creates important performance disparities like apparently here.

  • Default User Avatar

    As a quick first test I ran a few of the most recent accepted solutions and oldest solutions (see below) using Node v14.x (results for other nodes in parentheses). Indeed, some of the recent solutions time out. Maybe they passed with older nodes, but I tested that for only one. The three oldest solutions all pass consistently by a wide margin. There is some significant variation in time for subsequent attempts, possibly connected to server load. I ran these tests on a Saturday afternoon European time.

    Conclusion, the kata still works. It is not enough to have just any logarithmic complexity algorithm. Also the code needs to be performance optimised. This is possible: monadius' solution is on average 15% faster than my initial solution.

    I hope that helps. Good luck!

    recent sollutions:

    old solutions:

    • my initial solution: 8743ms, 8603ms, 8610ms (Node v10.x 8228ms, Node v12.x 7157ms)
    • solution by dfhwze: 8302ms, 9648ms, 10015ms
    • solution by monadius: 7794ms, 7963ms, 6388ms
  • Default User Avatar

    Of course, thanks for looking into it!

    Let me know if I can be of any help by providing more details.

  • Default User Avatar

    I'll look into that. Just give me few days, I am a bit on a tight schedule at the moment.

  • Default User Avatar

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

  • Default User Avatar

    First of all: I absolutely love this kata. On the surface it seems so simple... but its surface conceals many, hidden complexities. Thank you @zappa78!

    Unfortunately I also feel something is wrong with the Javascript variant, just like @zhirnov-d and @Iluxmas remarked 4 days and 17 days ago. Perhaps due to an update, as @Iluxmas suggested?

    I have written quite a performant algorithm (tests complete in 733ms, that's even about 16 times faster than @Iluxmas), but still I get remote timeouts. While remotely all '10000 big numbers' and all '100000 big numbers' pass, the final category '1000000 big numbers' times out.

    I came to believe that something is wrong because of three reasons:

    1. the purpose of this kata, I would guess, is to write an algorithm that does not have a liner time complexity O(n), but has logarithmic time complexity. After all, that's what the description says: it was inspired by the other kata that could be solved with a O(n) loop. If this was the test, I have passed.
    2. Remotely, I pass almost all tests, just the last category fails. Hence it seems to be a minor tweak (not a fundamental problem) that causes the fail.
    3. The remarks of others, who have also been experiencing issues recently.

    What do you think of this, @zappa78?

    I will try to share my solution in a comment to myself, so that I can set a spoiler flag.

  • Default User Avatar

    Should rather say that the horizon is the limit, eh?

  • Loading more items...