Ad
  • Custom User Avatar

    Sorry for late reply.

    Your if statement is wrong. After sorting the array (example) [1,2,3,2,1], it looks like this [1,1, 2, 2, 3]. But your if statement does this:
    if ( 1 == 1 && 1 != 2){returns true} (1 == 2 && 1 != 2){returns false} and so on...

  • Custom User Avatar

    You are not tackling the problem correctly.

    The fact that the half of the length of the array equals the size of the set, doesn't mean that every number in the set occurs twice.

  • Custom User Avatar

    Any response on this one?

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Default User Avatar

    Wrong tests?

  • Custom User Avatar

    Very helpful!!

    Ne zameram, s obzirom da mi je prva kata ocekivala sam prepravke. Nisam ocekivala ovako detaljno objasnjenje, hvala ti, nesto sam i naucila! :)

  • Custom User Avatar

    Hey, Johan. The author was unfamiliar with random testing so I tried to add some basic random tests and explain it briefly. Since I edited the kata already I added a test to make sure input array isn't modified and a sentence in description to notify future solvers not to modify input. I think it's better now.

  • Custom User Avatar

    I believe tests are ok now :)

  • Custom User Avatar

    Your random tests are vulnerable to input modification. This can be fixed as simple as Test.assertEquals(twins(Array.from(arr)), myTwins(arr));

    Also, in my unhumble opinion it would be good practice to specify the user solution must not change its input, and check for this.

  • Custom User Avatar

    Hvala Stefane, nadam se da je sada ok? Sta su random testovi? Jos uvek nisam pohvatala sve ovde.

  • Custom User Avatar

    Wrong tests... see my "unfinished solution"...

  • Custom User Avatar

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