Nice recursive solution. I didn't think of this solution. It took me some time to understand what the creator of the Kata meant. The description was kinda vague.
It is a good solution. I would suggest that you do: input.ToLower() .ToCharArray() .ToList() etc. Then you have more readable code. If you look at my solution you see how it can be achieved without using the dictionary. But it is still a good solution :-)
Thanks. I like your implementation of extension methods. Makes a lot of sense and allows a first-to-last method call notation rather than the last-to-first one I am forced to use.
Thanks! Most interesting thing I learned about here, was the use of the (?i) in a Regex, to make it act case insensitive.
It is like the /...../i in Perl, which I really missed and for which I really disliked using the extra RegexOptions.IgnoreCase argument.
Info on that can be found at: https://msdn.microsoft.com/en-us/library/yd1hzczs.aspx
Quite a big solution for the type of problem, but nicely partitioned and easy to read.
And best of all: when you had written your own unit tests, then this structure would have worked well for a TDD approach.
A small remark: variable 'consecutives' did put me off a bit during my first read through.
I expected that to be a list of, well... consecutives.
It could have been named something like 'summedConsecutives' to make it represent its actual contents better.
binaryCalculation *= 2;
if (binaryCalculation == 0)
binaryCalculation = 1;
if (BinaryArray[i] != 0)
binaryRepresentation += binaryCalculation;
The first three lines are about making up the value for binaryCalculation, so they should be grouped:
binaryCalculation *= 2;
if (binaryCalculation == 0)
binaryCalculation = 1;
if (BinaryArray[i] != 0)
binaryRepresentation += binaryCalculation;
Looking at those three lines, things can be simplified a bit.
When assigning the value 1 at the start of the function to binaryCalculation, the multiplication can be moved to the end of the loop:
if (BinaryArray[i] != 0)
binaryRepresentation += binaryCalculation;
binaryCalculation *= 2;
Nice recursive solution. I didn't think of this solution. It took me some time to understand what the creator of the Kata meant. The description was kinda vague.
It is a good solution. I would suggest that you do: input.ToLower() .ToCharArray() .ToList() etc. Then you have more readable code. If you look at my solution you see how it can be achieved without using the dictionary. But it is still a good solution :-)
Thanks. I like your implementation of extension methods. Makes a lot of sense and allows a first-to-last method call notation rather than the last-to-first one I am forced to use.
Your solution looks almost as mine only i would recommend to implement the transformations as extensions :) looks more clean. For the rest good job!
Sweet! Same solution :)
Thank you for pointing that out! I'll have a look ...
Thanks! Most interesting thing I learned about here, was the use of the (?i) in a Regex, to make it act case insensitive.
It is like the /...../i in Perl, which I really missed and for which I really disliked using the extra RegexOptions.IgnoreCase argument.
Info on that can be found at: https://msdn.microsoft.com/en-us/library/yd1hzczs.aspx
Damn, I didn't think about this approach. This is going to my favourites! Love the LINQ style :-) ...
Thanks! My goal was to make the entrance code as clean as possible and really easy to read.
Quite a big solution for the type of problem, but nicely partitioned and easy to read.
And best of all: when you had written your own unit tests, then this structure would have worked well for a TDD approach.
Good point, its indeed a sum and not an assignment.
A small remark: variable 'consecutives' did put me off a bit during my first read through.
I expected that to be a list of, well... consecutives.
It could have been named something like 'summedConsecutives' to make it represent its actual contents better.
Same solution? Ha! Ur looks fine to me as well :-)!
Thanks for the feedback, good point. I wasn't aware of that.
The grouping inside the loop is a bit confusing:
The first three lines are about making up the value for binaryCalculation, so they should be grouped:
Looking at those three lines, things can be simplified a bit.
When assigning the value 1 at the start of the function to binaryCalculation, the multiplication can be moved to the end of the loop:
Regards,
Maurice
Loading more items...