7 kyu

Empty that array!

Description
Loading description...
Arrays
Fundamentals
  • Please sign in or sign up to leave a comment.
  • ejini战神 Avatar
    • Node 12 should be enabled (Refer this and this for more info)
  • Souzooka Avatar

    I'm kind of confused by the Kata. Is the lesson it's trying to teach the one taught in the top solutions?

  • JohanWiltink Avatar

    Your recursion detection code is inadequate.

    I am actually mainly pointing this out because I do not like to be told I can't recurse.

    • ben8p Avatar

      I changed the test, should be way harder to recurse now :)

    • JohanWiltink Avatar

      Well, actually, no. Sorry. :P

    • ben8p Avatar

      This comment has been hidden.

    • Voile Avatar

      Make the array very big?

    • JohanWiltink Avatar

      A performance test would probably work, and might catch otherwise undesirable (to you) solutions.

      A bulletproof solution against recursion specifically might be implemented with a proxy for the solution function, which increases a counter before calling the underlying function, and checking that counter.

      Question remains: why would you want to forbid recursion or iteration? If you're concerned about performance, just check performance. If you don't want solutions other than the canonical one, in my unhumble opinion you're just shortchanging yourself (and others), impeding creativity and elegance. What's wrong with the ocasional different solution, even if it's not the most efficient for this problem? It might be adaptable to a different problem, and have its use there. This platform isn't always about solving this problem, sometimes it's useful for getting ideas to solve a different one. Why not give it the chance to function as such?