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.
Yes, you can paste your tests here and mark the comment as spoiler. Thanks!
Did you manage to figure this out? What is 's' and what is 'xs'? Former should be a list and the latter an 'int'?
Ha, it's funny that you're actually the creator of the kata. An example of why programmers shouldn't test their own code ;)
There should be tests with decorating functions returning falsey values. This solution wouldn't pass them, and it's accepted as of my writing. Is there a way I can suggest a modification for the test (aka a "pull request" for the kata)?
This solution is flawed. If
@before
returns a falsey value,args
will be passed tofn
instead of the actual value.Likewise, if
@after
returns a falsey value,result
will be returned instead of the said value.It's really nice though, I combined it with a better check that won't throw away falsey return values and submitted that as my solution.
In the python version, the instructions use a different signature for the function. Also, function parameter names suck.
Duplicate of http://www.codewars.com/kata/is-a-number-prime.
Please add a power of two to the test cases. That would invalidate incorrect solutions like this, which don't check for divisibility by two.
It took me really long to understand why the call to
new Singleton
works here.In case anyone happens to get puzzled by it, the constructor will return
undefined
the first time around (asinstance
hasn't been set). That causes thenew
keyword to create a new object inheriting fromSingleton
's prototype. After that,instance
will be returned normally by the constructor.Who voted "Best Practices" on this? ...
There is of course a much higher performance penalty when using higher level languages. Invoking a function in JS costs a lot more than in C.