Ad
  • Custom User Avatar
  • Custom User Avatar
  • Default User Avatar

    I have an issue in c++ code, in this test
    vector numbers { 1,100,50,-51,1,1 };

    In my IDE output is: 1, but in code wars i have output -1.

    This is my code

    int find_even_index (const std::vector numbers) {
    int sum_r = 0;
    int sum_l = 0;
    for(int i = 0; i < numbers.size(); i++){
    for (int l = 0; l < i; l++) {
    sum_l += numbers[l];
    }
    for (long int r = numbers.size(); r > i; r--) {
    sum_r += numbers[r];
    }
    if (sum_l == sum_r) {
    return i;
    } else sum_l = 0; sum_r = 0;
    }
    return -1;
    }

    Please help me find out what is the problem

  • Default User Avatar

    C translation (author gone)

  • Custom User Avatar

    JS:

    • Node 18. (mocha + chai) should be enabled

    • function name should use camelCase

  • Custom User Avatar

    Description is quite terrible, with even no answers shown for the examples, and sample code having different examples.
    Especially "We need to check ALL of the substrings inside of 877692" is very ambiguous.

  • Custom User Avatar

    Description has "1st position of the array" which is technically incorrect use of English where first indicates no other object comes before it, which in this case is incorrect. Better would be to use "at index 1 of the array" for 0-based arrays. Same for other instances.

  • Custom User Avatar

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

  • Default User Avatar

    Change "Your job is to return the middle character of the word" to "Your job is to return the middle character(s) of the word" :)

  • Default User Avatar
      assert_eq!(get_middle("ƒoo"), "o");
    

    I suggest to add this casetest too because the string "ƒoo" contains a non-ASCII character, which may behave differently than ASCII characters in certain operations.

    for example the len of ƒoo is 4 not 3.

      assert_eq!("ƒoo".len(), 4); // fancy f!
    
  • Custom User Avatar

    Hi guys, I really don't know what to do. The test passes without errors, random selection also passes without errors. But an error occurs in FindEvenIndexTest -> testIt

    How to understand it

  • Custom User Avatar

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

  • Custom User Avatar

    The input is a string (with no spaces) containing [a-z],[A-Z],[0-9] and common symbols.

    common symbols should be defined. They are not the same in different languages.

    Moreover Python random tests don't even include digits.

  • Default User Avatar

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

  • Default User Avatar

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

  • Loading more items...