Ad
  • Default User Avatar

    small optimization in terms of avoiding code repetition: instead of incrementing the count variable in both the if part and the else part you could do it before or after the if statement, just once

  • Default User Avatar

    or cast to BigInteger. (BigInteger) Math.Pow() is the same as BigInteger.Pow()

  • Default User Avatar

    Most likely because whoever wrote this didn't realize it can be solved in O(1). Or because this kata is listed in the section "LINQ excercises" so the author tried to solve it using System.Linq library. I don't think it can be solved in O(1) using language integrated query.

  • Default User Avatar

    the cast to int is not necessary

  • Default User Avatar

    While using a stack for this is clever it's actually bad practice because it increases the space complexity of the function. A simple integer getting incremented or decremented is enough for this problem, no need for stack.

  • Default User Avatar

    this is bad practice, instead of using multiple if, use else if. else if only checks the other conditions if the first one resolved to false, yours will always be checked in any case. Also the last if should be moved inside the scope of second if to only check it if the current parenthesis is a closing parenthesis.

  • Default User Avatar

    nesting ternary is not bad practice. Nesting Ternary without using parantheses to increase readability is bad practice.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Looking at your function I would expect the result to be ending with a whitespace, what Am I missing here? You join every line with an ending line switch, also the last line where we dont want a line switch anymore right?
    So I would expect line 10 to have an ending line switch in your solution but there is none. Thats so confusing to me. I personally didnt use the -join option but used a different approach and there I had to use an if statement to see if its the last line, to only add a line switch when its not the last line. Or I could simply remove the last one with the Replace method but its so weird to me that you dont have to do any of that here. Why does the output from your solution NOT have a line switch after line 10??? someone please explain

    Edit: I just found out how it works. For those who struggle understanding this solution: Google how the join method actually works in the background. Cuz I thought it would append every line but it does not. Its rather defining a seperator for the join. So the line switch only occurs in between two lines.

  • Default User Avatar

    The first Assert in the kata is not correct tho, correct me if I'm wrong. It Asserts there are 50 ip addresses in the given range but there are 51 actually. Whoever wrote this Assert just calculated the difference but its actually always the difference + 1 , because you count the 0 too. Somehow it does not matter if your solution returns 50 or 51 here, it will both be accepted as a correct solution. Is that a bug or a feature? :D I saw submits return 51 here while mine returning 50 here was also accepted.

  • Default User Avatar

    The Assert expects 50 as result for the first Difference but should be 51.

    Since from 10.0.0.0 to 10.0.0.50 you have 51 adresses, not 50. You can choose the zero as well

  • Default User Avatar

    mad respect for solving this with Linq only. Without any knowledge of IpAdress class. You are sick man :D

    Showed this to my colleagues we were very impressed

    Just one thing: when I cast your method on start = "10.0.0.0" and end = "10.0.0.50" it returns 50 but should be 51. From 0 to 50 you have 51 adresses to choose ;) so just add 1 to it somehow

  • Default User Avatar

    In the C# unit tests that the kata provides one of the tests will cause errors which are not my fault. The test is simply missing the parenthesis from invoking the method PageCount(). It is used like a property but was supposed to be a method. itemscount was supposed to be a property but PageCount was not.

    Thats why my code will always crash with an error and a line reference in that unit test saying I would use a method group like an object.

    In my code editor I run all the tests perfectly fine. Its really just the parenthesis missing for invoking the method in one of the Asserts.

    Please fix

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    The error's line reference is also kinda suspect because it refers to a line where I barely have any code and definetly no method group being used as an Object. Could this be a problem with the compiler, runtime or stuff like that?

  • Loading more items...