Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Done: users are going for very bad and inefficient approaches, it has nothing to do with the test code. I would gladly implement something to deal with it, but right now CW is refusing to save any edit to the kata.
You are evidentely modifying the array in place, which is bad practice unless required.
Also, I see no part of the description forbidding the use of negatives, but I can quickly fix that (and it has nothing to do with the problem).
Actually I fear your code was faulty, needlessly modifying the array in place. Fixed that, so that even not so efficient and bad practice solutions might work.
Actually modifying the array is considered bad practice if unnecessary.
Btw, I upvoted myjinxin2015, as he definitely deserved it.
Hi myjinxin2015 ! I modified my code following your advice and it worked.
I imagine approximately why the random tests failed, interesting anyway :)
Thanks !
Giacomo, could you please address the issue above?
This kata is not supposed to be passing negative values. Let me look into this.
I can't edit the test cases right now. Can someone provide access to edit my Kata pls? :p In the meantime, I've gone and changed the title and description to match the test cases.
myjinxin2015: even though I think it's not correct approach and evaluation of tests should be independent of the modification to the original array (it still returns correct sum, doesn't it? and why it works with initial tests but not random?) you're right that it helps to pass the random tests. Once I changed code the way it works with copy of original array it works fine.
Anyway, you are not sensei of this kata and thanks for advice
I just said some advice, if you don't agree you can ignore it.
But why did I get a
downvote
? Unhappy :(please check your code, make sure that you haven't modified the original array ;-)
And same suggestion to other guys ;-)
Agree Test seem to be broken
Testing for [-6, 478, 82, 880, -27, -683, -793, -3]
✘ It should work for random inputs too: -1476 should equal -710
And same suggestion to other guys ;-)
please check your code, make sure that you haven't modified the original array ;-)
Random tests seem broken, or I didn't understood the challenge :) :
[ 1003, 100, 99, 39, 30 ]
✘ Expected: 199, instead got: 69
[ 1011, 98, 20, 68, 29 ]
✘ Expected: 166, instead got: 49
[ 1043, 28, 97, 73, 68 ]
✘ Expected: 170, instead got: 96