Retired

Find place of 2 elements in array (retired)

Description
Loading description...
Algorithms
Arrays
Data Types
Arithmetic
Mathematics
Logic
Numbers
  • Please sign in or sign up to leave a comment.
  • twypsy Avatar

    You should make some tests in order to return an empty array.

  • JohanWiltink Avatar

    .. a solution that doesn't use brute force

    Nobody (so far) takes advantage of the fact that the input array is sorted. But why would we, when even the example solution doesn't ?

    What is the point of this kata? What are you trying to showcase with your example solution?

  • GiacomoSorbi Avatar

    As stated below, use either Test.assertSimilar or Test.assertDeepEquals to avoid this:

    Expected: [0, 4], instead got: [0, 4]
    Expected: [1, 5], instead got: [1, 5]
    Expected: [1, 4], instead got: [1, 4]
    Expected: [1, 5], instead got: [1, 5]
    Expected: [5, 9], instead got: [5, 9]
    

    Grouping tests might also be good, same for random testing. I assume you either published by mistake or didn't look at the errors when you hit the button; let me know if I might help in fixing stuff :)

  • donaldsebleung Avatar

    I'm pretty sure a similar Kata has been authored before already but I can't find it yet - if I find it then it makes this Kata a duplicate.

  • donaldsebleung Avatar

    Other Issues with your test cases:

    If there is no correct answer, return an empty array.

    AFAIK that isn't tested at all in your Test Cases. Either remove it from the Description or add edge assertions to address it.

    Find a solution which doesn't use brute force.

    Again, the tiny number of assertions in your Test Cases means that any brute-force solution can easily pass all tests without timing out. If you really want to prevent inefficient solutions from passing, enforce it. Add such a large number of random assertions in the Test Cases that even the most efficient solution just completes under 12000 ms (Codewars code execution time limit). Otherwise, I would suggest simply removing it from the Description.

  • donaldsebleung Avatar

    Codewars Forums - Kata Best Practices - Have Full Code Coverage

    Expected: [0, 4], instead got: [0, 4]
    Expected: [1, 5], instead got: [1, 5]
    Expected: [1, 4], instead got: [1, 4]
    Expected: [1, 5], instead got: [1, 5]
    Expected: [5, 9], instead got: [5, 9]
    

    I haven't actually managed to pass the tests yet (see my other Issue posted below) but every time I run "Attempt", I get the exact same failed output which shows that your tests are not randomly generated at runtime.

    Having only 5 fixed assertions in your entire test suite is unacceptable and far from sufficient from preventing logically flawed and/or hardcoded solutions from passing. Please either (1) increase the number of unique, distinct fixed assertions to at least 20 including edge cases or (2) even better, write 100+ random test cases as per standard Codewars practice which is generally preferred over just 20+ fixed tests.

  • donaldsebleung Avatar

    Test.assertEquals cannot be used to compare two arrays; use Test.assertDeepEquals instead.

    • donaldsebleung Avatar

      Fixed - now at least the Kata is actually completable (I had to forfeit eligibility just to fix the Kata).

      BTW @Tova7 not sure how you even managed to publish this Kata in the first place but mind you, your "Complete Solution" was actually buggy and resulted in an infinite loop so I had to replace it with my (working but somewhat inefficient) solution.

      Issue marked resolved by donaldsebleung 8 years ago
    • JohanWiltink Avatar

      You can publish a kata without a working solution. You can't re publish it, but you can publish it. (So to change it, you can unpublish first.) It's a known bug.