6 kyu

Equal Sides Of An Array

8,685 of 131,795Shivo
Description
Loading description...
Algorithms
Arrays
Fundamentals
  • Please sign in or sign up to leave a comment.
  • danielAyerra Avatar

    Hi there, I am having doubts about Length 2 sized arrays. When n=0, there is nothing at the left (because there is no -1 position), so the answer should be 1 if position 1 equals to 0. When n=1, there is something at the left (position 0) and nothing to the right (last position), so the answer should be 0 if position 0 equals to 0.

    So I don't understand why {8,8} should be 1! I mean, n is not being counted, but the numbers at the left and at the right of n, isn't it? Am I misreading something or missing something?

  • Areyousick Avatar

    chrono is the goat

  • blemanoe Avatar

    Easy task but requires attention and some time... Proud I was able to pull it off

  • WatchAssassin Avatar

    This one was challenging but was fun to complete!!

  • Ishboi 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?!

  • mrFuture99 Avatar

    Maybe I'm understanding it wrong but if the test is (3, {1,2,3,4,3,2,1}) shouldn't it be 1 because it says return the lowest index and 1 equals 1

  • Crite Avatar

    test is broken The array was: {8,0} Expected: 0 But was: -1 The array was: {8,8} Expected: -1 But was: 0

  • skilltrik2222 Avatar

    test.assert_equals(find_even_index([-15,5,11,17,19,-17,20,-6,17,-17,19,16,-15,-6,20,17]),8) it is incorrect, right answer is 9

  • EisKekks Avatar

    Python kata problem: Prepared 3rd and 2nd test cases give wrong answer:

        test.assert_equals(find_even_index([10,-10]),-1)
        test.assert_equals(find_even_index([-3,2,1,0]),3)
    

    Both should be 0 (or am I stupid???)

  • ndegz Avatar

    Very nice!

  • acseh01 Avatar

    I did not find any indication in the description of this kata that if multiple indexes exist for a given array, the first index should be returned. I have a failing test for the input [0, 0, 0, 0, 0] and the test suggests that the correct answer is index 0. Any index of this array should be a correct answer in my opinion, as again, there was no indication that if multiple indexes fulfil the requirements the first (or leftmost) is the correct answer. Correct me if I am wrong, but I believe the test in this case are biased towards the solution. All my other tests pass.

  • fatih-bilgin-kko Avatar

    Anybody solved the problem in last one in the basic cases in attempts?(in Python)

  • gc______ Avatar

    Rust issue. Instructions expect to return unsigned -1 for no available solution, check is for None in this case.

  • pedrohcleal Avatar

    dont understand my result log:

    The array was: [20,10,-80,10,10,15,35]: expected -1 to equal +0

    +0 ???

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

  • supersonic_dragonfly_ Avatar

    C++ issue; Test 1: given the vector 3, 1, 0, 3, 0. Expected result is 0, actual result is -1 (+1 on my machine). This is blatantly wrong. Test 2: given a vector with a lot of zeros which I will not bother typing. Expected result is 9 (blatantly wrong), I have not tested this on my machine but looking at test 1 is enough for me.

  • Mart1518 Avatar

    It prints that -1 is the wrong answer, and says that the correct answer is +0. And how to solve this?

  • JohanWiltink Avatar

    LC translation

  • unlink.unperks Avatar

    This comment has been hidden.

  • RoterHust65 Avatar

    This comment has been hidden.

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • timmcwilliams Avatar

    This comment has been hidden.

  • JarecMadeTech Avatar

    The tests are broken. In places the return values are 0 where they should be -1

  • timmcwilliams Avatar

    Why won't my return i give me the value. It is in the if statement. i does equal what I am asking for but it will not return and goes thru the next arr.

  • Zam7am Avatar

    How can I get the arrays that are used to verify your attempt? I keep failing a test, because it expects 1, while my program outputs -1.

  • temujin Avatar

    When I try to attemp the solution codewars tell me that a test fail, because it spect -1 as answer, and when I run the same code in local, response with -1 not with +0....

  • lopatuxin Avatar

    Hello, is it possible to somehow deduce the expected result from the tests. Otherwise, the test crashes, I display the source array, but I don't understand what the test expects at the output

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

  • fokfm Avatar

    This comment has been hidden.

  • Sebo1411 Avatar

    This comment has been hidden.

  • JoshuaCF Avatar

    There's an issue with the Rust version of this kata. According to the problem description, "if you are given an array with multiple answers, return the lowest correct index". This is not true in the Rust translation. Here is an example where it breaks:

    [5789, 7078, 659, -8368, -1095, 360, 5335, 4182, 8784, 3830, 2452, -4398, 4410, 4608, -7401, 3961, -7297, -5611, 7955, 9161, 1562, 1952, 9472, -1753, 5727, -8722, -8811, -9806, -9466, -3573, 6676, 7551, -2884, -7086, 8519, 9270, -2223, -5293, 8054, -4715, 85, -4782, 1494, 831, -2437, -2135, -6001, 3968, 9474, 6190, 7201, -6982, -1150, 469, 1806, 1725, -7172, 5396, 238, -7497, 5832, -1861, -5153, -7039, 2128, 2939, -1313, 3239, -9301, 1996, 5304, -9884, -138, -1445, -6853, 8668, 3299, 1154, -2733, 2285, -3715, 5695, -9500, 3303, -2737, -8601, -5807, -984, 8727, -8406, 7191, 3376, -1435, -2765, -5389, 3566, 3852, 4488, 6611, -4183, 4237, -8503, -4649, 4124, -7322, -1897, 793, -1746, 1349, -4642, 708, -5744, 7057, 7476, 7184, -8886, -6100, -4159, -9482, 1360, 8613, 7757, 5915, -2201, -694, 9151, -54, -6794, 1895, -1122, -4630, 798, -7008, -8878, -9491, -5909, 7831, -9401, 3313, 1427, -8889, 6521, -4197, -8411, -2145, -6102, -2512, -9066, -9214, -8084, 2972, -5576, -5121, -4287, -7635, -4836, 6, 790, -1418, 5979, -922, 7362, -2533, -3569, -4611, 438, -1707, 4295, -2770, -2566, 8889, -4414, -170, 589, -5493, -6894, 2989, 2506, 6505, 1112, -2640, -4028, -3474, -4150, 432, 5009, -5154, 3296, -2099, 6939, -7892, -6705, 2397, -1236, -7946, 8157, -9251, -8327, 4076, 4189, -2035, -2599, 5079, -6689, 4122, -4986, 2211, -6599, -4882, 3159, -6876, 1198, -5061, 6341, 19, 7800, 4074, -3371, -1198, 9149, 9930, -155, 7428, -8635, -8210, -7346, -8099, 4497, -9643, -7382, -9787, 7954, -761, -9015, -9516, -7925, 1910, -843, -72390]
    

    This random test expected an answer of Some(202) which IS a valid answer, but my code returned Some(199), which is ALSO a valid answer and has the lower index.

    This happens when the kata tries to generate a random test with a guaranteed answer but doesn't check that its answer is the lowest valid answer, instead just assuming it's the only answer. This is easy to fix -- just replace dotest(&arr, Some(i)) with dotest(&arr, reference_solution(&arr)) (and probably do a slight refactor to get rid of the extraneous else block). I have a proposed fix here: https://www.codewars.com/kumite/649c7f7f0b00c8003ea81022?sel=649c7f7f0b00c8003ea81022

  • ZiomaleQ Avatar

    This comment has been hidden.

  • ChuikinaMaria Avatar

    This comment has been hidden.

  • mathwhiznht5 Avatar

    Hey just a bit stuck. I seem to get everything to pass on the test, but not the attempt. I understand that the submit runs a ton of random tests on top of the basic tests. I pass all the random tests that are added, but fail one of the basic tests that I believe tests for a situation in which the total is 0 and the index is needed for returning is 0. Let me know if you want more information, but I am just not able to fathom the problem at this point. Appreciate any help.

  • misha11 Avatar

    This comment has been hidden.

  • joaoghabriel1 Avatar

    This comment has been hidden.

  • darghal Avatar

    since arr<1000 , it's obvious that the program is O(n^2)

  • wubajono Avatar

    This comment has been hidden.

  • masykurm Avatar

    This comment has been hidden.

  • comp-phys-mark Avatar

    This comment has been hidden.

  • ang11 Avatar

    This comment has been hidden.

  • Hamervit Avatar

    Hi, I'm getting this error on test [ The array was: [20, 10,-80, 10, 10, 15, 35] : expected -1 to equal 0 ] but the entry array is [20, 10, 30, 10, 10, 15, 35].

    I'm working with JavaScript Node v14.x. Also I test the entry array with my code and the result is 3 not 0.

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

  • ofersadan85 Avatar

    The Rust kata has a small bug, the initial function signature is

    fn find_even_index(arr: &[i32]) -> usize
    

    But the tests expect it to be

    fn find_even_index(arr: &[i32]) -> Option<usize>
    

    Fixable by the user but should be fixed in the kata

  • younesib Avatar

    This comment has been hidden.

  • hobovsky Avatar

    COBOL translation, I don;t know COBOL and just copied it from another, duplicate kata, so please review carefully.

  • AlexDRichards Avatar

    I could be wrong, but I don't think my code should have solved this problem. For example, if my method were given the following array [1,2,3,4,5], it would compare, at index 1, (1+2) against the sum of (2..5), because I coded this way: .each_with_index {|e,i| if arr[0..i].reduce(:+) == arri..-1...}, but my code soved the tests. The instructions asked for the sum on either side of the index to be equal, not including the index position number, but that's not what my code does, but my code passed.

  • Flashbangcodes Avatar

    My code works for all the core test but fails a random test. I can't figure out the issue and I can't find an array that it wouldn't work on: (code in replies)

  • hobovsky Avatar

    This kata is a subject to deduplication process here: https://github.com/codewars/content-issues/issues/166.
    Please join the discussion to help us identify duplicate kata and retire them.

  • Labi123 Avatar

    please somone help me, my solution works perfectly on my computer but does not work in codewars:

  • HoneyJaar Avatar

    This comment has been hidden.

  • KuroDess Avatar

    I think the test [1,2,3,4,5,6] will return the answer 3. it is because 1+2+3 is 6. If it is my misunderstand please tell me, thank you.

  • markgtd Avatar

    There is a seemingly wrong test: "The array was: [8]: expected -1 to equal 0". The test seems wrong because the left side is an empty array that sums to 0, and the right side is [8] that sums to 8; thus, the index of 0 does not lead to equal sums.

  • KayleighWasTaken Avatar
  • tri@ Avatar
  • M-Shehzad Avatar

    the test case array was [-3, 2, 1, 0] expected: -1 my code returned 3 which was correct since the left side of my code equaled to 0

  • rodrigoslayertech Avatar

    The array was: [10,-80,10,10,15,35,20] : expected -1 to equal 6

    Is wrong?

    index 6 => 20 (the last index)

    It can't be the first or last index because it compare sides.

  • kerofx Avatar

    '0 should equal -1' 11th basic test what is this?

  • Chrono79 Avatar

    If you are given an array with multiple answers, return the lowest correct index.

    This is only tested by chance, there should be (at least) some fixed test about this condition.

  • Miran_Amer Avatar

    This comment has been hidden.

  • akar-0 Avatar
  • CookieNinja Avatar

    This comment has been hidden.

  • Eqvvi Avatar

    This comment has been hidden.

  • commoncents Avatar

    This comment has been hidden.

  • khardrix Avatar

    This comment has been hidden.

  • jhonat23 Avatar

    A really nice kata!

  • Anianor Avatar

    I can’t understand what the problem is: on the test check it says that everything is successful (You have passed all of the tests!:)), but when I want to complete the test it says "Test Failed Expected: 1 But was: -1"

  • akar-0 Avatar
  • megerous Avatar

    Hello. How to find which test was failed?

  • Mahmud113 Avatar

    How to print -1 instead of None?

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

  • jekasachan Avatar

    I just spent 2 hours of my life trying to find a mistake instead of taking a proper look at problem description.
    Read your manual before turning the appliance on! :D

  • leticiachiu Avatar

    How [1,2,3,4,3,2,1] should return 3, if 1+2 equals 2+1? the kata says "If you are given an array with multiple answers, return the lowest correct index."

  • PessimisticHope Avatar

    The array was: [20,10,-80,10,10,15,35] : expected -1 to equal 0

    How is it supposed to be a 0? The sum of all integers does not equal to 0.

  • primevaldad Avatar

    In case anybody misread like I did: "sum of the integers to the left of N is equal to the sum of the integers to the right of N"

    I interpreted this as sum of N from the left == sum of N from the right, and I couldn't understand why the first test failed on [1,...,1] which returns 0 (in my incorrect code).

    Read carefully! Thanks for the kata.

  • Acheron76 Avatar

    This comment has been hidden.

  • Grovre Avatar

    Challenge users to do it in O(n)

  • Grovre Avatar

    I like how the slowest solutions are the "best practices"

  • Idkkitsune Avatar

    My code passed all but one basic test, but.. I don't know what was the array of the basic test

  • vilemSuchy Avatar

    I got 50 correct test and 1 incorrect saying: The array was: [10,-80,10,10,15,35,20] : expected 0 to equal 6

    Hos is this correct? 10=(10-80+10+10+15+35+20) right??

  • artem-barabash Avatar

    My soltion passed all of the test, expect last test, where write: "expected:<-1> but was:<0>". Language is Java, Thanks.

  • 0utrunner Avatar

    Trying to utilize the reduce function correctly for this problem was throwing me for a real loop! If you're trying to reduce an empty array like I was it will always throw an error. You'll need an initial value first. Feels nice having my first rank up.

  • ResisNex Avatar

    As soon as I saw the condition of the problem, I wanted to skip it, but I forced myself to take up the problem and it actually turned out to be very interesting and not difficult at all!

  • user7154500 Avatar

    Excellent kata

  • Serhii.Maksymov Avatar

    Hi, everybody. I don't understand why my solution fails one test. I have problem with the array [10,-80,10,10,15,35,20] (kata gives an error: expected -1 to equal 6), my solution gives as result -1. Why this test fails? All other tests are passed. Thanks a lot.

  • acessor Avatar

    There is definitely a mistake in the checking class on line 14. The integers sum do not match so in should return -1

    assertEquals(1,Kata.findEvenIndex(new int[] {2824, 1774, -1490, -9084, -9696, 23094})); to assertEquals(-1,Kata.findEvenIndex(new int[] {2824, 1774, -1490, -9084, -9696, 23094}));

  • SmuntCasher Avatar

    This comment has been hidden.

  • mtt1926 Avatar

    The answer of the test case that has input [-3 2 1 0] should be 3. However, it has -1 as an answer which should be fixed I think.

  • yaa123 Avatar

    This comment has been hidden.

  • admcsp Avatar

    I've got some error "Testing for [14, -3, 5, -6, -14, -5, 5, -6, 0, -3] It should work for random inputs too: 6 should equal 5" Here the correct answers are 5 and 6. My solution gave the result 5, and I got this error. Of course I corrected my code so it gives the result 6 without any mistakes. But now I don't know how to understand this task's instruction with the following "Note: If you are given an array with multiple answers, return the lowest correct index."

  • anton.andreytsiv Avatar

    This comment has been hidden.

  • samuel-ang Avatar

    This comment has been hidden.

  • falul Avatar

    This comment has been hidden.

  • jnester22079 Avatar

    This comment has been hidden.

  • Daisy_Duis Avatar

    This comment has been hidden.

  • Colmonkey Avatar

    This comment has been hidden.

  • Alphanaught Avatar

    Seems difficult at first but after looking at it for a bit it's quite simple... Nice kata!

  • 4arlz Avatar

    interesting kata, though not difficult

  • wooczak Avatar

    This comment has been hidden.

  • sc0rp1on Avatar

    This comment has been hidden.

  • kenshin30 Avatar

    I have issues with this problem. Test cases fail on this array: {1,2,3,4,3,2,1,1,100,50,-51,1,1,1,2,3,4,5,6,20,10,30,10,10,15,35,8,8,8,0,0,8} My solution returned -1, but the test expected 1, which is impossible since there is no way that the numbers on the right side after first position will evaluate to left.

  • mytrofanov Avatar

    This comment has been hidden.

  • sharp-ID Avatar

    Hi everybody,

    my issue is in JS.

    For some reason, i dont understand it, my Kata-Solution workes in VS Code but not on the same test cases in CodeWars.

    I dont know whats wrong.

    thank you for suggestions. :)

  • poggio.seb Avatar

    I have the below one that failed saying :

    Testing for [-17, -20, 19, 7, 17, -12, 17, 19, -30] It should work for random inputs too: 0 should equal 5

    --> I fully disagree it should be indeed 0 - as the sum of all numbers = 0

    Am I missing something?

  • ptressel Avatar

    This comment has been hidden.

  • cursedstuff Avatar

    This comment has been hidden.

  • marcelobastos.dev Avatar

    If I do console.log(index) it returns the right value. But if I do return index, it says it's undefined.

  • shivesh01 Avatar

    This comment has been hidden.

  • Marcelckp Avatar

    Great Kata Thank You creator!

  • DrewS97 Avatar

    How do what the test is that I'm failing? This is all that shows up:

    Test Results: ValidateWordTest GenericTests Test Failed Expected: 0 But was: -1 Completed in 78.4560ms RandomStringTests Completed in 169.1130ms

    Thank you for any help!

  • user1927036 Avatar

    My code passed 9/10 tasks and 1 problem is this: ''' -1 should equal 3 Log [20, 10, -80, 10, 10, 15, 35] 0 ''' i dont understand, why it should equal 3, my answer '0' is right ... and what '-1' is all about .. ?

  • impossibleDarer Avatar

    This comment has been hidden.

  • carlthecoder Avatar

    Not sure why, but when I run the test in Visual studio it works, yet here I am getting a type mismatch error: /home/codewarrior/program.fsx(18,17): error FS0001: Type mismatch. Expecting a 'int * int []'
    but given a 'int * int [] * 'a'
    The tuples have differing lengths of 2 and 3

    But I am not using any tuples and the function is just returning an integer for the index. (so function signature is: int array -> int

    I am getting same error if just return any random integer.

    Can anyone help

  • El_Romario Avatar

    This comment has been hidden.

  • Alpsboy-Jin Avatar

    Nice kata! I'm a beginner and this took me 2 hours + to finish it but definately difficult compared to most of other 6 Kyu questions! Thanks for this!

  • dummyaccount Avatar

    This comment has been hidden.

  • mspmanish Avatar

    For the below test input in Attempt,test is failing for me but when i run the same in my local machine it returns the true answer -1. [1,2,3,4,3,2,1,1,100,50,-51,1,1,1,2,3,4,5,6,20,10,30,10,10,15,35,-8505,-5130,1926,-9026,2824,1774,-1490,-9084,-9696,23094,4,5,6,7,8,9,10,9,8,7,6,5,4,8,8,8,0,0,8]

    Anyone has any idea why this is happening?

  • RNOH Avatar

    nice kata!

  • alanparmenter Avatar

    Perhaps I'm being pedantic, but 0 < arr < 1000 doesn't look right to me for the length of the array in the description, since the name arr is in use as the name of the array itself. Wouldn't it be easy to spell out the range of lengths of the array without notation? For instance, 'There will be fewer than one thousand elements in the array.'

  • pie_thon_prince Avatar

    is there a way to view "Basic Test" input? receving the following output: "Passed: 57 Failed: 1 Exit Code: 1"

  • doctone Avatar

    This comment has been hidden.

  • redplait Avatar

    how it can be after pressing test button I got: You have passed all of the tests! :) and after pressing attempt button: CoreTests failed on the same code?

  • Rostecki Avatar

    This comment has been hidden.

  • Jillsea Avatar

    Somehow this was challenging. At first I was like "maybe this test is broken" then I tried to reach the right answer even if the test was broken.

    In the end it wasn't broken but when I tried to understand how it worked it made me see things I couldn't before which was essential to undertand where was the problem in my code.

  • RahulKumarGautam1636 Avatar

    Something wrong with this Kata. My code passes all 50 tests except one for input [20,10,-80,10,10,15,35] which expects 0. but according to question o/p must be equal to -1. the o/p will be 0 only if the number 20 on the 0th index is removed. please correct me if i'm wrong.

  • JotaKSantos Avatar

    I cannot submit my code. I get the error:

    Parse error: syntax error, unexpected '=', expecting ';' in /workspace/default/_solution.php on line 8

  • ShubhamKaudewar Avatar

    This comment has been hidden.

  • freakQubit Avatar

    In description is: "Input: (...) The numbers in the array can be any integer positive or negative." And then in tests there is for example [0,8]. Zero (0) is neither positive nor negative so the description is wrong.

  • jakubsvec Avatar

    Testing for [42, 9, -4, 3, 1, 9, 8, 0, 5, 17, 0, -16, -1, 20]

    Failed attempt: 0 should equal 3

    42 + 9 - 4 = 47... (index 3) ... 1 + 9 + 8 + 0 + 5 + 17 + 0 - 16 - 1 + 20 = 43

    1. there is an error, but it is not in my code, 47 is NOT equal to 43...
    2. when I run my code with this dataset in Python, it actually returns 1, not 0, so there is another problem as well
  • jakencox Avatar

    This comment has been hidden.

  • jakencox Avatar

    has anybody solved this on ruby?! i've read that its flawed... maybe thats why im struggling? any hits of what direction to take would be great!

    thanks!

  • Partha689 Avatar

    No errors in output failed=0 in Attempt but says MAX buffer size reached!!!!

  • Partha689 Avatar

    I don't get any error in ATTEMPT but I gave an error says MAX buffer size reached.

  • wisecobra01 Avatar

    there is something wrong with the c# kata my tests pass but one of the attempts fail

  • devagx Avatar

    im having issues with hidden test case in java. Anyone getting same? test case is below. It says my code returns 0 running the kata here, but i run my code in my IDE and its returning -1 which the Kata expects. 1, 2, 3, 4, 3, 2, 1, 1, 100, 50, -51, 1, 1, 1, 2, 3, 4, 5, 6, 20, 10, 30, 10, 10, 15, 35, -8505, -5130, 1926, -9026, 2824, 1774, -1490, -9084, -9696, 23094, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 8, 8

  • dhruvk Avatar

    This comment has been hidden.

  • TomislavStipic Avatar

    This comment has been hidden.

  • Thimras Avatar

    This comment has been hidden.

  • jbaxe2 Avatar

    This comment has been hidden.

  • tshjones Avatar

    This kata is broken for C#. Same input is used in two different test cases at least and gives me two different results ensuring it's impossible for me to actually complete this kata. I've even tried randomizing the output between 0 and -1 to try to get around it but that hasn't worked yet, but the array [1,2,3,4,5,6] wants both a 0 and -1 answer, which is ridiculous. I pass all the randomized test cases with flying colors.

  • Ali-Masarwe Avatar

    I think that this test is wrong (c++):

    { vector numbers { 1,2,3,4,5,6 }; int expected = -1; Assert::That(find_even_index (numbers), Equals(expected)); } I think the answer should be 3 because left side {1, 2, 3} is equal to {6}

  • RyanCrosby Avatar

    I'm new to using codewars, so this may be a silly question. When clicking 'test' everything passes and works fine. When clicking 'attempt' it fails. Does this mean that there is something wrong with my code? Does 'attempt' use a different set of tests that are hidden?

  • contreras2 Avatar

    This comment has been hidden.

  • Tez47 Avatar

    This comment has been hidden.

  • fjod Avatar

    This comment has been hidden.

  • mahaKarzoun Avatar

    This comment has been hidden.

  • Jaizkibel Avatar

    Groovy Translation submitted.

    Would be nice if someone could review it

  • norewaaa Avatar

    This comment has been hidden.

  • ahmed-maher Avatar

    My code passed all of the tests when I test against sample tests, but a test case failed when I attempt to pass the full test suite. How can I know which one?

  • technicholy Avatar

    how is Test.assert_equals(find_even_index([20,10,30,10,10,15,35]),3) a valid test? "20" and "35" are not the same thing.

  • user5557224 Avatar

    I am new here, so I hope I am going about this the right way.

    My code passes all but one of the tests. It fails the test on the list: [-3, 2, 1, 0]. Since the list is small, we can look at it and know that our functions should return 3.

    On my machine, my code returns 3. But it fails the test: the test says my function returns 2 and that it should actually return -1.

    Is anyone else having a similar issue? What can be done about this? Perhaps I am missing something?

  • lucasbndv Avatar

    this test is buggy. It worked on my local machine:

    find_even_index(list(range(1,100))) # error = 1 should be equal to -1

  • anvanster Avatar

    embedded tests looks buggy. it passes all tests on local machine

  • Asuno Avatar

    This comment has been hidden.

  • KVN78Dnepr Avatar

    This comment has been hidden.

  • Adipta Biswas Avatar

    {} is NULL and NULL is of type 'None', whereas 0 is of the type 'int'. I am getting an error in Testcase 5

  • RastallM Avatar

    This comment has been hidden.

  • MdmaSteel Avatar

    This comment has been hidden.

  • rge123 Avatar

    Is there a perfomance version of this somewhere?

  • motioblur Avatar

    Hi! I'm having an issue where I can't pass one of the tests. I receive this input: [-3, 2, 1, 0]. My script tells me the answer should be the 3 index, an I agree, but it still gets marked as an error. I think it's because the solution doesn't count empty arrays to actually have a value, but in one of the examples they say so but with index 0. Am I wrong here? Is there somewhere in the instructions where they explicitly state this case, or am I missing somo concept here?

  • GonzaloMonteodorisio Avatar

    This comment has been hidden.

  • Huntersoulz Avatar

    This comment has been hidden.

  • spademarck2020 Avatar

    This comment has been hidden.

  • restrukt Avatar

    This comment has been hidden.

  • MALIKMUHAMMADWAQAR Avatar

    This comment has been hidden.

  • bedlamagogo Avatar

    This comment has been hidden.

  • EmperorMigx Avatar

    Okay I got it now so basically this problem tells (this was not explained in the description but according to the sample test cases) that there is a DMZ like north and south korea between left side and right side. I should've seen the pattern. Thank me later my fellow coders.

  • aditnole Avatar

    This comment has been hidden.

  • rhm05 Avatar

    This comment has been hidden.

  • Arkadeep Mitra Avatar

    This comment has been hidden.

  • user2570191 Avatar

    writing in python, this test is going on:

    Testing for [-15, 5, 11, 17, 19, -17, 20, -6, 17, -17, 19, 16, -15, -6, 20, 17]

    and it returns to me:

    It should work for random inputs too: -1 should equal 8

    i did, also calculated myself, got the same result as my program, but test somehow thinks index 8 (17) is the right answer.. o.O

    p.s. this aint only one failing like this

    EDIT: i edited my program a bit, and it eventually passes, but on some occasions it would fail. passes like every 4th or 5th time. dunno what is going on, but nice work, that was interesting!

  • typhoon132 Avatar

    I failed a basic test (I passed 54/55 tests) but can't see what values were used as it seems to an 'extra basic test'. The random tests and the initial 10 basic tests give their test values. Any idea how to get this info? Thanks

  • Mo_Tab Avatar

    This comment has been hidden.

  • VecSpec Avatar

    This comment has been hidden.

  • learner1205 Avatar

    index error when using python 3.6 in testcase with Range()

    switching to python 2 seems to remove it

  • Epagelmatias Avatar

    This comment has been hidden.

  • Ramon049 Avatar

    cool kata :)

  • CMJ Avatar

    When I'm trying to use and learn from nice JS best practice solution from "okeydoke80, wrousse, cucubau3000, eriksudd, qu3rn, yy123 (plus 32 more warriors)" it can't pass the test from description for the array {20,10,-80,10,10,15,35}. Q: Why? Am I doing smth wrong? My solution passes all but it's quite straightforward...

  • stellartux Avatar
  • DrGit Avatar

    This comment has been hidden.

  • MistahMoose Avatar

    This comment has been hidden.

  • Suubterr Avatar

    This is array that is run in tests: 1,2,3,4,3,2,1,1,100,50,-51,1,1,1,2,3,4,5,6,20,10,30,10,10,15,35,-8505,-5130,1926,-9026,2824,1774,-1490,-9084,-9696,23094,4,5,6,7,8,9,10,9,8,7,6,5,4,8,8,8,0,0,8 Somehow expected value is 1 when sum of it is -12924 so even if I'm at index 1 the amount on the right side of it is -12923 and it is not equal 1. Please fix it.

  • JasonMRoos Avatar

    Part of what makes this Kata's instructions confusing is the vague use of the word "position" combined with its reference to the "index" as if it were an ordinal, e.g., "the first position."

  • schlaBAM Avatar

    How does this make sense?

    Expected: 1, instead got: 0 Log: [7, 3, -3]

    This contradicts the last example given in the details.

  • tbuyar Avatar

    This comment has been hidden.

  • maximus-lewson Avatar

    I completely missed the fact that N is to be excluded when I read the description. Could you highlight it a bit more ? For example like this:

    "[...] integers to the left of N is equal to the sum of the integers to the right of N, excluding N. [...]"

  • Einherjar  Avatar

    When I tried to run the haskell unit tests I got:

    The name of the test module must end with 'Spec'

  • Mirus Avatar

    This comment has been hidden.

  • diegoaurino Avatar

    This comment has been hidden.

  • BlueFlag23 Avatar

    how does {20,10,-80,10,10,15,35} have expected result is 0?

  • yinwei Avatar

    This comment has been hidden.

  • AflahB Avatar

    There's no consideration/tests for overflow arithmetic. Particularly useful in C/C++ where AFAIK signed integer overflows lead to undefined behaviour.

  • andypbarrett Avatar

    This comment has been hidden.

  • khris78 Avatar

    This comment has been hidden.

  • Chrono79 Avatar

    Tests with a single element (and maybe with 2) should be present in all languages.

  • Zemez Avatar

    What is true for [1]? 0 or -1?

  • FArekkusu Avatar

    Python 3 should be enabled.