Ad
  • Default User Avatar

    Hi @Jchristian297 - for this kata, if you specify an index i, then the "left sum" is all elements to the left of i not including i itself and similarly for the "right sum" is all elements to the right of i not including i itself

    So let's look at [5,6,444,2,7,2]:

      idx 0  1   2   3  4  5
         [5, 6, 444, 2, 7, 2]
          [---]  X    [----]
    

    In the above illustration, the answer is index 2 because to the left we have 5+6 = 11 and to the right we have 2+7+2 = 11. NOTE WE DON'T INCLUDE 444 in either sum.

    For your test case [10,-80,10,10,15,35,20], if you say index 0, then the sum to the left of element 10 is 0 and the sum to the right is -80 + 10 + 10 + 15 + 35 + 20 = 10 != 0.

    The correct answer here is index 6 because, to the left of index 6 we have: 10,-80,10,10,15,35 (note how we don't include 20) and to the right of index 6 we have 0. And 10 -80 + 10 + 10 + 15 + 35 = 0 as required.

  • Default User Avatar

    One of the tests I am failing is ([10,-80,10,10,15,35,20]),6), but I don't see how 6 is the right answer. My code says index zero which seems to check out since 10 does equal -80 + 10 + 10 + 15 + 35 + 20. At index 6 it is saying that 20 = 10 - 80 + 10 + 10 + 15 + 35 but it doesm't, it equals 0. Am I doing something wrong or is this test just incorrect?

  • Default User Avatar

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