Ad
  • Custom User Avatar

    Five years ago I re-wrote this solution as a one liner using linq, and in the comment section I explain how it works.
    If you are interested, look there. I'm not sure why this answer has more "Clever" votes. It was just an intermediate step!

    This is probably still the worst code I've ever written.

  • Custom User Avatar

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

  • Custom User Avatar

    "and your partner" is a really easy change.

    It's easy to be inclusive. If the kata is written using "You" then don't bring gender/race/religion into it.

    Coders can figure out how to use variables, they can figure out how to make problem descriptions more inclusive.

  • Custom User Avatar

    The original text is virtue signaling. I'm asking for equality.

    If your culture or values are intolerant, that's your problem.
    Asking for equality for literally half the people in the world shouldn't be offensive anyones values. I don't think we should welcome a culture of misogyny here.

  • Custom User Avatar

    d is the poorly named static string array.

  • Custom User Avatar

    I want to be annoyed by this answer, but using only one collection for the test verification is just so lazy.
    I don't remember other kata on codewars where you can have a method return a single integer and pass all tests.
    I do hope comment art doesn't become "a thing" in general on this site.

  • Custom User Avatar

    Sure, Enumerable.Range is the reasonable choice, but then you are losing at code golf by 7 characters.
    Instantiating an array and using the index from a select override only takes twice as long to run through the test cases.
    It's easier to win at code golf when nobody else knows they are playing.

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    Thanks for the complements! I actually use the IPAddress class for work fairly regularly. Codewars is where I tend to write rediculous one liner linq answers just for fun.

    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

    The Kata description says "returns the number of addresses between them (including the first one, excluding the last one)"
    That is why 50 is the correct answer.

  • Custom User Avatar

    C# 8.0 in the wild
    Nice use of the new range operator.

  • Custom User Avatar

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

  • Loading more items...