Ad
  • Custom User Avatar
  • Custom User Avatar

    C Fork

    • empties pre-loaded
    • makes tester visible in sample tests
    • adds default return value
    • updates testing format
    • makes tester static
  • Custom User Avatar

    I would just like to let you know that the testing code has been updated. Please copy your code, click the RESET button in the trainer (the new tester will replace the old old), then paste back in your code, and try running it. You will see a different formatting of complete available information for that test. Please let me know what you think! And best of luck debugging your code submission for this kata.

  • Custom User Avatar

    approved

  • Custom User Avatar
  • Custom User Avatar

    you should really start using a macro to compute array lengths, when they are determined by an initializer list (e.g. int array[] = {1, 2, 3};).

    There is a mistake that demonstrates the dangers of hardcoding: you have two arrays of tests in the fixed and sample tests, one is of length 4 and the other of length 3; but you copied over the sample tests' loop code to the fixed tests:

    const int tests[4][2] = {
    //      input, expected
        {   1,     1 },
        {   8,    36 },
        { 100,  5050 },
        { 213, 22791 }
    };
    for(size_t index = 0; index < /* !!! */3/* !!! */; index++) {
    

    this would never happen if you instead let the compiler do the work for you:

    #define ARRAY_LENGTH(array) ( sizeof(array) / sizeof *(array) )
    
    const int tests[][2] = {
    //      input, expected
        {   1,     1 },
        {   8,    36 },
        { 100,  5050 },
        { 213, 22791 }
    };
    for(size_t index = 0; index < ARRAY_LENGTH(tests); index++) {
    
  • Custom User Avatar

    Okay bro I edited it , you can see the problem now

    please tell me if it need more explaination or fixing errors

  • Custom User Avatar

    retired

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    C Fork

    • adds default return value
    • udates testing format
    • provides complete error message feedback
    • streamlines RTG
  • Custom User Avatar

    Hi, and welcome to Codewars!

    Sorry, but your solution is incorrect. The error message feedback for the Sample and Fixed tests shows you this:

    The expression (summation(8)) == (36) is false.

    Which means for the input 8 sent into the function summation() result in the output of 36 which is not the expected output. The output should == something else, but it doesn't tell you that piece of information.

    The random test looks a little different:

    Expected: 29646 Received: 243

    This does tell you the expected result of 29646 should have been received from your function, but instead the testing code received an incorrect output of 243. Meanwhile, this testing format leaves something else out, which in this case is the actual input for the test that was failed...

  • Custom User Avatar

    You are welcome!

    As you can see, you still do not have Random Tests. Simply because they are always the same answer for every test run, they can be known; so they are not at all random.

    Please read the guidelines from the first link I gave you.

    Also, here is the official documentation on specifically: writing random tests.

    Best of luck!

  • Custom User Avatar
    • no random tests (Python)
    • JavaScript boilerplate ages code should be deleted / removed
  • Custom User Avatar

    It is very much not resolved look at the tests lmao

  • Loading more items...