Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Precomputations enabled by a small input domain are not cheats, they're optimisations.
Newer JS versions have
BigInt
, which would allow for a larger input domain. That might actually solve this "problem". Scanning source code for patterns is a losing proposition.Damn, I just wanted to post this after I completed the kata :D
verbatim what i wrote too! Party!
Just a small detail: \w refers to
[a-zA-Z0-9_]
(so it also contains the underscore and digits).What? It's the most time efficient solution
The arity of the function does need to be taken into account. Since only functions which have already been declared may be called, the intepreter has all of the information it needs to make that call.
As a more general example, take the following expression in Polish (prefix) notation:
A prefix interpreter knows that
+
is a binary operator, so it takes the1 2
as the arguments to+
, then*
takes the resulting3 2
, resulting in 6.Likewise, in your example the interpreter knows that
echo
is a unary function, so it takes only the first argument in the stack.Hope that helps. If there was any particular part of the description that led you to believe that arity wouldn't need to be taken into account, please let me know and I will try to clarify that section.
Thank you very much. You have helped me alot. Not only you have helped me to improve the kata description but I have also gotten a English class for free. Thanks again!
This comment is hidden because it contains spoiler information about the solution
Yes you're right: English is not my native tongue. I would be very grateful for your help. Thanks!
This comment is hidden because it contains spoiler information about the solution
no real reason. probably still mentally stuck in if/else syntax from other languages. if I were to write the solution again, I would likely use if