Ad
  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar
    // class is partial,
    // Firstname and Surname dictionaries are defined on other part of partial
    // you can access them directly here
    

    Yet when you try to access the property:
    'Kata' does not contain a definition for 'Firstname'

    Capitalizing the N in name seems to work (just for FirstName, Surname is correct apparently). Please fix the comments so we don't have to waste time guessing at someone's property naming style, and fix the partial class to use consitent naming.

  • Default User Avatar

    I don't think there's anything wrong with condensing code, especially when you are taking advantage of language features, as long as what you're doing in the condensing isn't incredibly difficult. Writing code vertically helps when debugging, and there is absolutely nothing wrong with it. When you're writing quite a lot of code, or repetitive code, sometimes you decide to use the languages features to save you time/gain performance. I would think by this time you have an understanding of the underlying concepts (reference vs value, heap vs stack, classes, pointers, interfaces, etc) which allow you to do more complicated things in shorter amount of lines (although line counts are a bad metric to measure performance or elegance!)

    To me, the following is reasonable and readable.

    public IEnumerable<int> DoSomethingInteresting(IEnumerable<int> values) => (values?.Count() ?? 0) == 0 ? new List<int>() : values.Where(x => x % 2 == 0).Select();
    
  • Default User Avatar

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

  • Default User Avatar

    Why is it outside of your control? Is the setup.cs file something that CodeWars maintains?

  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

    .ToList() converts your array from one IEnumerable to another IEnumerable. .Select() iterates over each object in the IEnumerable collection, .Where() then filters every one of those items, and .Sum() iterates through the now filtered ones and sums it up. You're iterating through the collection 4 times, rather inefficient.

    Since T[] implements IEnumerable, you can use Linq directly off it. So arr.Where(x => x > 0).Sum() would cut the number of iterations in half. Also, since 0 doesn't do anything to your sum, leaving it out could reduce the number of values Sum needs to operate on.

    Just some food for thought.

  • Default User Avatar

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