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.
IF you swap the positions of any of the special characters with each other, your solution won't notice -- among other false positive errors.
Of course a regex is not NECESSARY, but it is a very concise and clear way to solve the problem.
Please use spoiler flag next time.
Its harder to understand your solution. Is it really better than regex?
Could anyone provide an explanation to this answer? Thanks :)
I think what OP means is reusing input values, not necessarily "mutating" them.
The input values are
Number
primitives. They can't be mutated.What you call WET, someone else might call readable.
Much Better!!!
Your RegExp solution is not more efficient. RegExp, in general, is slower than looping through. Although, for a simple case like this, the difference is minimal. The issue with your solution is that you are also sorting. This makes it much slower.
Also, re-defining the argument is fine, especially for such a simple function and non-referenced string type.
Agreed. Mine is fugly in comparaison... ;-)
Well, some of the upvoted solutions do not cover all the bases, or fail on some cases. I like to test them sometimes when they look kinda iffy.
what poor practices are you speaking of? looking for examples to avoid pitfalls in the future
spoiler!...
This comment is hidden because it contains spoiler information about the solution
Hey, sorry about that; I hadn't anticipated someone doing it that way. Unfortunately I can't do anything about this, because dinglemouse made a couple changes to my translation (he wanted output displayed to the user) and so my fork is deprecated.
Apologies :)
@Firefly2002
Rounding issue (see above) -- please fixLoading more items...