Ad
  • Custom User Avatar

    duplicate issue above

  • Default User Avatar

    I used the SUM method wondering if the tests would be vague enough to fall of it. It did... this test could easily be added to catch my sneaky solution.

            var test = new int[][]
            {
              new int[] {5, 5, 5, 5, 5, 5, 5, 5, 5}, 
              new int[] {5, 5, 5, 5, 5, 5, 5, 5, 5},
              new int[] {5, 5, 5, 5, 5, 5, 5, 5, 5},
              new int[] {5, 5, 5, 5, 5, 5, 5, 5, 5},
              new int[] {5, 5, 5, 5, 5, 5, 5, 5, 5},
              new int[] {5, 5, 5, 5, 5, 5, 5, 5, 5},
              new int[] {5, 5, 5, 5, 5, 5, 5, 5, 5},
              new int[] {5, 5, 5, 5, 5, 5, 5, 5, 5},
              new int[] {5, 5, 5, 5, 5, 5, 5, 5, 5},
            };
    
  • Custom User Avatar

    I also have this message,but I solved it by removing my console.log statement.

  • Custom User Avatar

    I see some wrong answers (checking only for SUMS), I guess the tests doesn't cover an example with duplicates but the same sum?

  • Default User Avatar

    I think -1 existed long before Java. And it's bad but it's consistent with the behavior of indexOf in JS. And falsy values in a language with falsy 0 aren't much better in this case (used in PHP for this kind of functions; using == instead of === results in a bug)...

  • Custom User Avatar

    I would replace the -1 result with a null/undefined/false, -1 index it's a Java relic limitation that should not exists in the first place. It is more confusing in JS because you can do string.slice(-1).

    Nice one really, all the basic algorithms should have at least 1 kata around here.

  • Custom User Avatar

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

  • Custom User Avatar

    I did. Done, thanks.

  • Custom User Avatar

    Why would you pass a String of numbers in the first place?

  • Custom User Avatar

    Do you mean DIGITS not numbers, please update the description because the results are very different.

  • Custom User Avatar

    This website is in English only at the moment (I don't see any buttons to change the language, at least), so it makes sense that a kata would be English focused if it isn't specifically targeting some other language.

    Also, English's silly ordinal number system makes the kata more challenging. Returning century + "世紀" is considerably easier than what you currently have to do.

  • Custom User Avatar

    I'd be happy to.

    The text you see there is written as a [comment](https://en.wikipedia.org/wiki/Comment_(computer_programming) so it just informs you and doesn't do anything. In software development there is a methodology named "Agile" which focuses on TDD (test driven development) - it's basically custom written testcases suited to the current project. The "Run Examples" section follows this concept so that the user can write their own custom testcases if they so choose so (it's optional). When creating a Kata the author has the option to either put the "Examples" full of examples testcases, or they can leave it blank and the TDD box will appear for custom written testcases.

    The testing framework on Codewars is custom and so these functions are premade & preloaded already for you. They are used for creating/authoring your own Kata and each function has a different purpose - see here for information.

    • test.expect checks if the actual and expected match through a Boolean value.
    • test.assert_equals checks equality between actual and expected

    blah blah blah look at the link before for more info

    Example

    Test.assert_equals(whatCentury("1999"), "20th", "With input '1999' solution produced wrong output")
    
    It runs the function whatCentury with the parameter "1999" and if the return value is equal to the expected value of "20th" it passes, else error is given.
    

    tl;dr it's for user custom tests

  • Custom User Avatar

    Indeed! Thank you very much for your answer!!!
    What is happening exactly when you launch the tests through "Run Examples" or "Attempt"? I mean behind the button... How these "sections" are organized? The following text is written in the exercise but I don't really get it. Could you explain a bit?

    TODO: Replace examples and use TDD development by writing your own tests

    These are some of the methods available:

    test.expect(boolean, [optional] message)

    test.assert_equals(actual, expected, [optional] message)

    test.assert_not_equals(actual, expected, [optional] message)

    You can use Test.describe and Test.it to write BDD style test groupings

  • Custom User Avatar

    I'm assuming you're clicking the "Run Examples" tab which is just a section for example test cases. Click "Attempt" to go through the actual testcases which allow you to pass and submit your solution.

  • Custom User Avatar

    If I write:

    def whatCentury(year):
    return True (=> with the indentation of course)

    Or even:

    def whatCentury(year):
    print(year) (=> with the indentation of course)

    In Python 3.4 the output is "error" without explanation... Do you know why?

  • Loading more items...