Plan and done for Oct-06-2018

What will I learn today?

Keep solving and submitting CodeWars assignments.

Done

Solved reverse or rotate assignment and the most interesting as always - what is considered as best practice and clever solution by other members. The give solution is definitely clever and declarative (I strive to be as declarative as I can) and I've learned some stuff from it.

  1. Dividing integer by integer in C# you'll get an integer and never a float/double/decimal. No decimal delimiter! Never. No need for Math.round or Math.floor. Short SO explanation.
  2. There is an Enumerable.Range(). It works almost like range() in Python: string.Join(",", Enumerable.Range(1,5)) will produce "1,2,3,4,5". Almost like Python but not exactly because in Python the upper bound isn't included in the result, and we have additional method overload with a third parameter as step for generating the sequence.
  3. There are two versions of Reverse() method: one is for List collection, another is for objects with IEnumerable implemented. First is in place, second returns IEnumerable compatible. The reasons are historical. For strings we can use both, but the second seems more declarative.
char[] charArray = chunk.ToCharArray();
Array.Reverse( charArray  );
string result = new string( charArray  );
string result = new string(chunk.Reverse().ToArray());