Ad
  • Custom User Avatar

    Why would you assume that? If test cases were wrong, the kata wouldn't be approved. The problem comes from the fact that:

    1: you're mutating the input string (rarely a good idea)

    2: the tests do not guard against this. First, your function is run with the mentioned string, which you mutate, and then the reference solution is run with what's left of the string, leading to unexpected results.

    #2 is actually an issue, and should be fixed. I already see some issues raised below about it, and I'm amazed that this issue hasn't been fixed for 4 years or something?!

    Still, I have to close it as duplicate (for now). Try to avoid mutating input where possible.

  • Custom User Avatar

    Wrong in what way?

    7kyu seems reasonable for most high-level languages (one of which you seem to be programming in).

  • Custom User Avatar

    I sort of rushed it, but if this changes the description in any way, maybe you could just add the line in question manually @g964 and resolve it that way.

  • Custom User Avatar

    So apparently my Prolog translation was generating random atoms, not strings. I published a quick fix here https://www.codewars.com/kumite/5e1c9fea42473c00300e516e?sel=667d9531de35874b97fcff8d

  • Custom User Avatar

    Oh, my mistake. I misread the first part of your code as I just read it as in English, not code :facepalm:

    You're right that it shouldn't pass, and I'm not sure how there isn't 1 test against that...

    Feel free to re-raise the suggestion (which should actually be an issue IMO), and sorry for closing it too early.

  • Custom User Avatar

    The description is very old and poor. Translations should've modified the description, but no one did...

    Still, for python it's quite obvious when you look at initial code and sample tests: it expects a regular function.

    As for the failing test, did you see which input fails? See https://docs.codewars.com/training/troubleshooting/#print-input

  • Custom User Avatar

    Here's a basic template:

    using System;
    using System.Collections.Generic;
    
    public static class Kata {
      public static IEnumerable<string> FriendOrFoe (string[] names) {
        Console.WriteLine( string.Join(", ", names) );
        return names;  
      }
    }
    
  • Custom User Avatar
    Console.WriteLine(names);
    

    Should do the trick. But make sure to return something that the function expects (you could just "return names" to avoid errors).

  • Custom User Avatar

    I know, and I don't doubt that :D But if x/y could go into double digits, this kata may have been ranked 7kyu. I'm not sure :P

  • Custom User Avatar
  • Custom User Avatar

    Notes:

    0 <= x <= 4

    0 <= y <= 4

  • Custom User Avatar

    I literally just opened up C++ trainer and I clearly see 2 sample tests. Care to explain what you mean? Did you delete "sample tests" code by mistake?

  • Custom User Avatar

    But then you could take a look at the "notes" section of the description and realize that this scenario would never happen. Specification > realism.

  • Custom User Avatar

    That may be subjecive, but given that there are mentions in description of constraints that include arrays of length ~100_000, that in itself should suggest "performance".

  • Custom User Avatar

    This code passed all the tests but it shouldn't.

    But... it doesn't? I ran this solution on sample tests and it failed 3 of them, and also 20+ random tests on attempt.

    There already are a few fixed tests like the one you're suggesting, so I don't think it's a valid suggestion (especially when the original premise is flawed).

  • Loading more items...