Ad
  • Custom User Avatar

    Confirmed. Thanks. Was C# 12 added to Codwars last month (Nov '24)?

    https://www.codewars.com/post/whats-new-on-codewars-november-2024

    The OP wrote this question 5 months ago. I wanted to share the idea of identity-functions as an FP practice to anyone interested.

  • Custom User Avatar

    Order should be already available on CW for kata which have been migrated to C# 12.

  • Custom User Avatar

    Anyone remiss about not having Order can use OrderBy instead with an identity-function as the key-selector.

    int[] items = { 4, 1, 3, 2 };
    
    var sorted = items.OrderBy(x => x); // prior to .NET 7
    Console.WriteLine(string.Join(", ", sorted)); // 1, 2, 3, 4
    
    var sorted2 = items.Order(); // available after .NET 7
    Console.WriteLine(string.Join(", ", sorted2)); // 1, 2, 3, 4
    

    If you are so inclined, you can dig as deeply as you like into the implementations and overloads of these Order/OrderBy methods with the source that MS provides online. Be aware that Microsoft has gone to great lengths to make these perform well. Older, simpler implementations are available at Microsoft's reference-source site -- but these are frozen in time and won't include the latest things like this Order extension.

  • Custom User Avatar

    Rejected due to

    • Missing initial solution setup

    • No random tests

    • Function name should be snake_case

    • import solution should be from solution import total_time

    • Description should be made language-agnostic

  • Custom User Avatar

    at the bottom of the documentation for Order(), it is written:

    Applies to: .NET 9 and other versions: .NET 7, 8, 9

    checking .NET version on Codewars:

    Console.WriteLine(RuntimeInformation.FrameworkDescription); // .NET 6.0.16
    
  • Custom User Avatar

    Thanks for your reply but this does not explain why Order use raises this error and most topic (mostly stackoverflow) are addressing different issues.
    Order and OrderBy as both part of Linq assembly normally. So why OrderBy will be defined and Order not, unless Order has been depracted in the language version of the kata.

  • Custom User Avatar

    You're likely looking for the OrderBy method instead.

    If you Google "linq order enumerable" you'll find this kind of information easily :)

  • Custom User Avatar

    C# experts is it that normal i have this message with System.Linq, System.Collections and System.Collections.Generic directives included in my solution ?
    error CS1061: 'IEnumerable' does not contain a definition for 'Order' and no accessible extension method 'Order' accepting a first argument of type 'IEnumerable' could be found (are you missing a using dire

  • Custom User Avatar

    What happens to sort method on array for JS with this kata ?
    Array.sort is not working and leave array unmodified. Kata does not specify blocking anything

  • Custom User Avatar

    Precision: New to c#
    $$$$
    I am having an error System.FormatException : Input string was not in a correct format.
    This is on the unit test code line cdecode.Helper.Array2DToString(ClosestWeight.Closest(s))
    The code itself run without any error and i have not change the output type so i am returning
    int[][] and here the return return new int[][] { result[index], result[index+1]};
    I guess the Helper method is from Nunit frawework but quick search unsuccessful. So what could cause the cdecode to throw error ?

  • Custom User Avatar

    Still BigInt capabilities are not disbled for some language. Kata translation should take this into account.

  • Custom User Avatar

    I have introduce a typo when trying to report the issue but yes it is definitvely C# code not in any other language. If you look on google many people having similar issue.
    Any way same code copy / paste on codewars again and it is runs !!

  • Custom User Avatar

    Your code runs on your pc, in Java I suppose? toString and toCharArray are Java method names, not C#. Please have a look at C# reference guide: https://learn.microsoft.com/en-us/dotnet/api/system.int64.tostring?view=net-8.0

  • Custom User Avatar

    Hey
    New to c# and i have a code that run on my pc but when i move it here, i start having different errors which is really strange for me

    Thing as could not convert int to string ex: 'long' does not contain a definition for 'toString' and no accessible extension method 'toString' accepting a first argument of type 'long' could be found (are you missing a using directiv and so on. Same for toCharArray,

    Convert inacessible though system namespace being included

    I don't have any complex setup on local

    <>


    Exe
    net7.0
    enable
    enable

    >

    That is all have so question is why i am having these kind on basic object reference error ?

  • Custom User Avatar

    Who vote best practises and clever ??

  • Loading more items...