Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • 31668662?v=4
  • 47304273?v=4

    Why was Voile's answer downvoted?

    Voile is correct - the example returns 6 because from the input (-2, 1, -3, 4, -1, 2, 1, -5, 4) you have to find the sequence which yields the highest sum.

    That (as Voile correctly states) is "4, -1, 2, 1" because 4 - 1 = 3, then 3 + 2 = 5, then 5 + 1 = 6. There are negative numbers before (-3) and after (-5) this sub-sequence so the sub-sequence in the result is the yields the highest sum.

  • 45463018?v=4

    It's a little tip, but it helped me a lot!

  • 7628223?v=4

    I can get the random test cases to pass sometimes, and not others.

    I had to rip out the random failling tests into my own tests to ensure it works.

  • Profile pic

    This kata is so weak(all negative number seq return 0.wtf!) that it not worth 5kt.

  • Profile pic

    Your solution maybe wrong.Try again.

  • 15850069?v=3

    Wow, this submission really tripped me up. I had to use a visualizer to see what was being done. Very clever.

  • 31668662?v=4

    array = [50,-16,-15,-24,-5, 22]

    expected = 50

    Subarray does not have to include multiple values; just one is enough.

  • 2930187?v=4

    We can't find it because tests are failing on random arrays. I beleave they are generated randomly each time I submit result. Here is the screenshot: https://ibb.co/f9cWq33

    Here are some examples:

    With input: [31,30,-5,-38,48,46,38,-35,49,22,-8,22,-27,-17,12,34,-31]
    Test Passed: Value == 202

    Log
    With input: [-9,47,1,15,-21,32,-25,36,49,-11,15,25,13,15,5,34,-22,38,-22,40,36,-19,6,-5,-21,-45,-10,-19,36,22,-1,-37,1,-25,-35,-31,49]
    Expected: 300, instead got: 215

    Log
    With input: [50,-16,-15,-24,-5,22]
    Expected: 50, instead got: 34

    Log
    With input: [-26,0,-46,-3,-12,37,-46,48,14,42,-35,-49,8,-41]
    Test Passed: Value == 104

    Log
    With input: [32,50,-5,-32]
    Test Passed: Value == 82

    Log
    With input: [2,-18,19,-20,25,-22,-7,-25,-39,31,-38,-6,10,-15,31,-10,48,3,-45,-19,-23,4,32,27,-29,4,36,44,9,46,-27,-42,-42,-22,15,43,-26,21,37,27,9,-42,9,-36,-4,-18,27,-33,-18,-21,45,34,4,37,7,2,26,22,-47,-15,49,-20,37,27,-13,-29,24,-18,-14]
    Expected: 238, instead got: 205

    Is it the thing I am missing?

    [50,-16,-15,-24,-5,22] // Expected: 50, instead got: 34

  • 25391135?v=4

    I searched there and didn't find it. In your first line print the array (console.log(arr)) and press attempt. After that we could check if the array is exactly as you say

  • 2930187?v=4

    It was in the section of random tests.

  • 25391135?v=4

    I tried to do it in JavaScript however I dind't find any test case with these sequence: -47, 5, -29, -34.Anyway your result -24 is correct.

  • 2930187?v=4

    One of the Kata's tests cases for JS expects that -47, 5, -29, -34 should give 5 . I do not understand how?

    Here are the all possible contiguous subsequences and their sums:

    sum(-47, 5, -29, -34) = -105
    sum(-47, 5, -29) = -71
    sum(-47, 5) = -42
    sum(5, -29) = -24
    sum(5, -29, -34) = -58
    sum(-29, -34) = -63

    The highest sum is sum(5, -29) = -24 which my code gives.
    My code works for the single example case provided in the description.

    What am I missing?

  • 25391135?v=4

    It's a great Kata.

  • Profile pic

    Can't run this kata with c#.
    Even if i write return 0.
    Solution.cs(1,11): error CS1585: Member modifier 'static' must precede the member type and name

  • Loading more items...