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.
I don't know what was on my mind when I wrote that. Looking at it now, this seems like a perfectly sensible and straightforward solution to me. I happen to like yours better because it doesn't pollute the function signature.
Why do I so rarely see a neatly organized object-oriented solution? Always procedural, procedural, procedural, and never a custom data structure in the mix. Makes me sad.
I think what OP means is reusing input values, not necessarily "mutating" them.
This comment is hidden because it contains spoiler information about the solution
The purpose of the exercise is whatever you make it to be within the specified constraints. I'd say this is a win. The alternative is a regular expression with complex look-behinds. My own version, which is nearly identical, happens to require the strings appear at the beginning--but even that may be excessively robust.
It's not best practice. A best-practice solution would make clear the intentions behind the implementation. This solution obscures the intentions--but, in doing so, wins the prize for "most succinct."
Good kata, but I think a requirement that the algorithm perform the sort in place would have made it more challenging and interesting. (Maybe an idea for a new one?)
Instead of overloading the return of n, you could set a "null function" as the default of op. (The null function would simply return its input.)
Instead of overloading the return of n, you could set a "null function" as the default of op. (The null function would simply return its input.)
Instead of overloading the return of n, you could set a "null function" as the default of op. (The null function would simply return its input.)
Instead of overloading the return of n, you could set a "null function" as the default of op. (The null function would simply return its input.)
What does it mean to "successfully" divide by 2 "before we reach an odd number"? Dividing by 2 evenly? Dividing by 2 such that the quotient is an even number? Both?
On the other hand, there doesn't seem to be any logical reason, given the stated requirements, why a single-letter vowel ought to return true and a string of only consonants ought to return false. It feels like the unit tests for these edge cases were added solely to bias the solver toward a particular solution--one which might not preserve the continuity between the problem and solution as well as one that behaved more logically.
So elegantly simple. Wow. So, when searching for something difficult to find, try searching instead for its opposite. Lesson learned. Thank you.
The number would have to be enormous--like, well beyond the memory limits of the input parameter itself--for that to make a difference. (Of course, if that's just your competitive goal, then hats off to you.)
Loading more items...