Ad
  • Custom User Avatar

    This is a very risky idea for a kata: easy to solve (with built-in random generators provided by standard libraries), and very difficult to test (testing for randomness id not an easy task).

  • Custom User Avatar

    iirc, such idea has been done before ~~ feel free to come to discord for a better / quicker response !

  • Custom User Avatar

    That's because your code is wrong. You need to improve it.
    There are some random test cases. They differ every time. So that's why you get different numbers of passed tests.

  • Custom User Avatar

    Please mark your posts as having spoiler content next time.

  • Custom User Avatar

    Yes, it can. Your solution has complexity of O(n^2), and is more or less equivalent to a loop nested in a loop because count goes through whole array every time.

    The kata can be solved in O(n), since it's enough to iterate over the array only once to solve it.