Ad
  • Default User Avatar

    "alr apporved some time ago"

  • Default User Avatar

    Hi, I made a Python translation for this kata. Please approve it.

  • Custom User Avatar

    Why would it expect Arsenal in uppercase if the instruction said to return it in lower case if the max reminder is an even number. Here is the example below.
    [ 56, 120, 119, 11, 20, 20 ]
    16
    Expected: ''ARSENAL'', instead got: ''arsenal''

  • Custom User Avatar

    I made a C# translation for this Kata.

  • Custom User Avatar

    There are solutions, like this one which should not pass as the upper bound of the length of a and b is not specified and potentially infinite.

    My suggestion is to test bigger arrays of random size in the random tests.

    Edit: Kata specifications say "The lengths of the first two arrays will be equal, and the integers will always be positive", but the last fixed test uses [0, 0] as an array.

  • Custom User Avatar

    There are now 50 random tests.

  • Custom User Avatar

    The point here is actually rather that a good test suite should:

    • Pass conformant solutions
    • Reject faulty solutions

    Failing to do the former properly is called a broken test. Failing to do the latter properly is still a broken test.

    People often just think about the former without the latter, but of course, as we know, tests that let everything pass is useless.

  • Custom User Avatar

    Done. You are right. I still wonder, though, why do people cheat on CodeWars? I mean, what is the point? Isn't the whole idea to challange yourself and try to solve the problem?

  • Custom User Avatar

    Can we have more than one random test please? Like, fifty or so?

    With a for loop that's not 50 times as much work, and it prevents hardcoded solutions. ( With just the one random test, a cheater has a 50% chance of being able to submit. Having to hit the Submit button, on average, twice is not a real deterrent to a would-be cheat. )

  • Custom User Avatar

    there will be no kata #1

    Bugger. :P

    Well, here's waiting for kata #3 then. I hope it'll have an own name as good as this one. :]

  • Custom User Avatar

    Indentation is whitespace from the left margin to the actual start of the line.

    In general, you want to keep blocks of code indented consistently, so you can see at a glance what lines of code belong to the same block. If you open a new block, you increase the indent; if you close it, you decrease it.

    This is your code, formatted according to one style of indentation ( there are more ):

    function kira(a, b, c) {
      var newArray = [];
      var reminder;
      for (i = 0; i < a.length; i++) {
         reminder = a[i] % b[i];
         newArray.push(reminder);
      }
      newArray.sort( function(a, b) { return b - a; } );
      if (newArray[0] % 2 === 0)
        return c.toLowerCase();
      return c.toUpperCase();
    }
    

    So it's purely a formatting thing. But it makes well-structured code easier to read.

    Note I have removed the enclosing curly braces from the bottom if; it's still immediately clear what statement(s) might be skipped if the condition fails because it's indented from the if () statement.

    Your original code is not consistent in its indentation, and not all code inside a block is indented relative to the start of the respective block. The structure does not stand out as much as it might. So one has to actually read every line of code to understand it, and see the structure that way ( it's there, of course ). Your code is not as maintainable as it might be.

    Does that answer your question?

  • Custom User Avatar

    Issues resolved, see the comment above.

  • Custom User Avatar

    Yep, you are rigth. Thanks for that feedback. Will now correct.

  • Custom User Avatar

    Typos on the description ...

    -The first two will always be arrays consisting of intigers => integers
    -Reminder instead of remainder

  • Custom User Avatar

    Thanks. Changed the name; there will be no kata #1; added an example test case; random test added; changed to 6kyu.

  • Loading more items...