Ad
  • Custom User Avatar

    approved

  • Custom User Avatar
  • Custom User Avatar

    Yes, I missed that. I was just coming back to say I figured it out why! :D Thanks!

  • Default User Avatar

    I don't know C# but looking at the the error message System.InvalidOperationException : Sequence contains no elements I'm guessing what's happening is you are failing on the 5th test case which is testing your code with an input of an empty array - as mentioned in description:

    "If you get an empty array/list, return an empty array/list."

    So you have to handle that case gracefully, however you implement those kind of situations in C# !

  • Custom User Avatar

    I understand what you are saying. I did it on C#. Still, for me, the input validation and trick requirements are a bit beyond 8kyu, especially if it happens to be your first time on Codewars too.

  • Custom User Avatar

    Ah, ok, now it makes sense. It is very weird to show all Logs into the same one though, it is the first time this happens.

    I updated my code and I get the correct result everytime just that now I have another weird issue: System.InvalidOperationException : Sequence contains no elements.
    What sequence and where and why, since I get the correct list at the end and I use a different list, not the original one, as it says not to mutate that one.

    Exit log with appropiate comment prints at the end to differentiate between test cases:

    min is 1
    2
    3
    4
    5
    end of test
    min is 1
    5
    3
    2
    4
    end of test
    min is 1
    2
    3
    1
    1
    end of test
    
  • Default User Avatar

    You have to remember that there are dozens of different languages in use on Codewars, and of course some features/tasks are considerably easier/harder than others depending on language - there are some 4-5 kyu katas that are trivial with some imported modules in Python for example (and no, I'm not telling you which ones they are :P)

    FWIW, this seems to have approx same number of solves in Python and Javascript (20,000 or so) which suggests it might originally have been a Python authored-kata; if so it doesn't seem too difficult for 8 kyu.

  • Custom User Avatar

    That's a problem with your code, not a kata issue, it's failing the second test.

    // first test
    1
    2   //input
    3
    4
    5
    
    2
    3   //output
    4
    5
    
    
    // second test
    5
    3
    2   //input
    1
    4
    
    2
    3   //output
    4   
    5
    
  • Custom User Avatar

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

  • Custom User Avatar
  • Custom User Avatar

    This is a level 7 kata. The input is an object array (some people barely even know arrays at 8 kyu), the input requires validation, there different requirements for both the positives and the negatives (making it confusing even if you got it right) and the output must be again an object array.

  • Custom User Avatar

    For C# I am very confused. The result is the expected one yet it reads it from the end?

    Whenever I Console.WriteLine the input list and the exit list I get a weird double list printed in between formed from the original list concatenated to the original list reversed and then the error comes because it reads somehow this reversed list?

    This is what I get (the first is the input and the last is the output and the output matches the requirement so it should be a passed test):

    1
    2
    3
    4
    5

    2
    3
    4
    5
    5
    3
    2
    1
    4

    2
    3
    4
    5

    Test Failed
    Expected and actual are both <System.Collections.Generic.List`1[System.Int32]> with 4 elements
    Values differ at index [0]
    Expected: 5
    But was: 2

  • Custom User Avatar

    Ok, now I can tell if something is wrong from my side. Thanks!
    L.E.: There, now I fixed it! Easier when the error message points the right way!

  • Custom User Avatar

    Fixed that, check your code and fix it.

  • Custom User Avatar

    Because actual and expected are flipped in random tests, your code is generating those nulls.

  • Loading more items...