Ad
  • Custom User Avatar

    Can't really understand the description for this one, {1,2,3,4,3,2,1} yeah s ure, 4 is the sum of both the left side and right side of the array.
    Then this {1,100,50,-51,1,1} the sum result of 50, -51, 1, 1 is the same as the first position in the array which is 1, sure ok.
    But now this part just makes me feel dumb:

    "You are given the array {20,10,-80,10,10,15,35}
    At index 0 the left side is {}
    The right side is {10,-80,10,10,15,35}
    They both are equal to 0 when added. (Empty arrays are equal to 0 in this problem)
    Index 0 is the place where the left side and right side are equal."

    The left side is empty? And Index 0 is the place where the left side and right side are equal? Whaaat?!

  • 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
      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

    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

  • Custom User Avatar

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

  • Loading more items...