Ad
  • 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

    Of course, thanks for looking into it!

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

  • 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?

  • Default User Avatar

    being able to understand this probably makes the author very apt at refactoring code bases...

  • Default User Avatar

    hahaha you really wanted a "one-liner" huh?

  • Default User Avatar
  • Default User Avatar
  • Default User Avatar

    How does the .reduce({}) work?

    If I try

    str = "a=1, b=2, c=3, d=4"
    str.split(', ').reduce({})

    I get an error:

    main.rb:5:in `reduce': {} is not a symbol nor a string (TypeError)