7 kyu
Empty that array!
588ben8p
Loading description...
Arrays
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Updated to Node v12
I'm kind of confused by the Kata. Is the lesson it's trying to teach the one taught in the top solutions?
The idea was to give more insight on what is called "variable by reference"
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.
I changed the test, should be way harder to recurse now :)
Well, actually, no. Sorry. :P
This comment has been hidden.
Make the array very big?
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?