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.
You should test that the function returns
true
when all needed characters are present (i.e. it recognizes all possible uppercase letters - 26 tests, recognizes all possible special characters - another 20 tests), not only that it returns falls when something is missing.Having programmed with .NET 2.0 most of the time, I never much got into contact with Linq until now - this solution just was the first that came to mind.
Looking at other solutions on this site I have learned so much more about Linq this week than I would ever have imagined before.
Hey-ey!
Thanks for the analysis. After viewing other solutions I was curious about the relative speed of this simple line.
10k runs is great but should your test randomly generate sequences of numbers?
This is a bit of a dirty trick on my part. X-P
There's actually no such thing as a "down-to" operator, it's just creative spacing. What this really is is a post-decrement operator (
--
) and a greater-than comparison (>
) squished together in awhile()
loop.So, it really should be written as:
Because it's a post-decrement, it translates to something like this:
You should never use this in production, it's more for a laugh. It relies too much on magic, and has an unexpected side-effect of
n
being one less than you would expect inside the loop. In fact,n
will exit the loop being-1
, even though the loop was testing against0
.I could only get away with it here because the value of
n
was not used inside the loop.