• What would you suggest changing?

  • super nasty and unclear!

  • Because the first one being a duplicate is 4, not 1.

    [1, 2, 4, 4, 3, 3, 1, 5, 3, "5"]
              |     |  |
              |     |  3rd duplicate
              |     2nd duplicate
              1st duplicate
    
  • 1 comes before 4
    so y in the answer 4 comes first?

  • the order when they first appeared as duplicates

    The example is ok, it's the tests that are using assertEquals after sorting that are wrong. They should use assertDeepEquals instead. Changed it.

    Read Azuaron's issue below too.

  • Wrong example.
    In the 1st example, for [1, 2, 4, 4, 3, 3, 1, 5, 3, "5"] input you have as a result [4, 3, 1] https://prnt.sc/ur0yij, but correct unswer for the same input is [1, 4, 3] https://prnt.sc/ur0y8j

  • When do you find the repetition?

     -3 10 9 -7 -3 9 10 -7 -8 -8 9 1 10 2 -3
                 | | |   |     |
                -3 9 10 -7    -8
    
  • Testing for -3 10 9 -7 -3 9 10 -7 -8 -8 9 1 10 2 -3

    It should work for random inputs too: [-3, 10, 9, -7, -8] should equal [-3, 9, 10, -7, -8]

    But what's wrong with this output?
    The first number that repeats is -3, then -10 then 9 and so on.

  • No, read the instructions again, about the first test:

    $this->assertEquals(3, count(duplicates([1, 2, 4, 4, 3, 3, 1, 5, 3, '5'])));

    The first number that repeats, parsing from the left is 4, then 3 and lastly 1, so the expected answer is [4, 3, 1] it has nothing to do with descending order.

  • In PHP some tests expect a descending duplicates array:

    Failed asserting that two arrays are equal.
    Expected: Array (
    0 => 4
    1 => 3
    2 => 1
    )
    Actual : Array (
    0 => 1
    1 => 4
    2 => 3
    )

    And others expect to return the duplicates array with the ocurrences order:

    Failed asserting that two arrays are equal.
    Expected: Array (
    0 => 4
    1 => 2
    2 => 6
    )
    Actual : Array (
    0 => 6
    1 => 4
    2 => 2
    )

    • no random tests in ruby
    • (some) tests use test_expect
  • Not sure the language you're coding in, but testing this in Python:

    Those are not the duplicates you are looking for.: [1, 3, 4] should equal [4, 3, 1]

  • One of the languages had a bug in its test cases that forced answers to be in a particular order. When people complained, instead of fixing the bug, someone changed the description to match the bug ("It's a feature!") That never should have happened. The intent of this kata was only to report duplicates, not to report duplicates in a particular order. Now, people are complaining that the answers which were valid for years should all be failed. I disagree. Changing the spec years after the original publication was the wrong move; the tests should have been fixed instead.

    Revert the description change. Fix the tests in all languages to be order agnostic.

  • I completed this kata somewhere around 2 years ago. The description at the time was:

    Given an array, find the duplicates in that array, and return a new array of those duplicates.

    Reading this discussion page, it seems people were complaining that--in a particular language--"If order of the output matters, it should be in the description," so on October 23, 2017 someone added that the order matters to the description. This person did not update every language to enforce that new rule.

    IMHO, changing the description was the wrong move. A 7 kyu kata for finding duplicates is fine; finding duplicates and preserving the order of their first duplicated instance is more like a 6. The tests requiring a particular order were bad, and should have been fixed instead of fundamentally changing the meaning of the kata years after its original publication.

  • This should be level 6 or 5 challenge, IMO.

  • Loading more items...