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.
Weird, I get 40 vs 41 lines (not instructions) with your code vs the previous post with "-O6" option.
Nice catch, we weren't checking for numbers being present. I had started with the initial version instead of the other forks from JS and focused on translation instead of being more diligent.
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.yay proper unit tests
since we're just returning true/false from each method, we can just return the conditional
Converted to separate functions for each test, and commented.
Array.every and Array.some express the intention of the loop better than a plain for or forEach.
Let's not override the thing that we're testing
the
flatten
method is overridden for the tests, so this solution doesn't work at allCleaned up the sorta cryptic variable names. Readable names trump sort names.
Nice. Somebody has read clean code and polymorphism. haha
Nice! I like how it's simple yet understandable on a first read through.
This is nice, but there is a lot of wasted cycles sorting and recalculating
Linq is a great framework for dealing with sets and lists, but often people use it as a fix everything and not really understand what is happening under the hood. For simple things, in my honest opinion, it's better to go with a pure C# solution instead of Linq to help increase the efficiency of the code. For complex things, then it's better to bring in Linq.
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.
There we go, a solution without using Linq
Loading more items...