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.
This comment is hidden because it contains spoiler information about the solution
So it was my intention NOT to use any non-integer calls ;)
Unlike
Array.Sort
, this version doesn't change the array that it is passed.We could change the
int[]
toIEnumerable<int>
without any other changes and this would continue to support arrays while allowing other collection types and queries to be passed to it --Array.Sort
works only on Arrays.This version is written as an expression-bodied member, the
Array.Sort
version cannot be written as an expression-bodied member -- it requires a code-block for the method body and a return statement.Yes,
Array.Sort
performs better, but this version performed well enough to pass the tests and has all the above benefits. I'll offer that best-practice is at somewhat subjective, but there are tangible reasons to appreciate this implementation.I don't know why this is voted as Best Practice. If you just call Array.Sort and return the element at index pos-1, benchmarking shows it will run over 10 times faster, without any allocations or garbage generation, and will be just as readable.
This comment is hidden because it contains spoiler information about the solution
It seems that nowadays new programmers almost forgot that performance is a valuable feature of every code.
I like how you incremented 'rot' when iterating the rotors instead of additionally iterating the remaining characters for every rotor like I did.
Only thing I don't like about it is that you concatenate the result strings in every rotor iteration. Would have been more performant to allocate char arrays and replace the elements then create a string from it when it's finished.
Seems like people are so obsessed with making a one-line solution that they have no regard for sensibility or performance.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I couldn't tell if you were being sarcastic at first
This comment is hidden because it contains spoiler information about the solution