Ad
  • Default User Avatar

    Thank you, that solved my problem :)

  • Custom User Avatar

    Oh, sorry. The last trained language on your profile was JS, so that was consistent with the usual mutation trouble and the way the tests were written.

    I just checked, and the expected result for this input is effectively 1... but the ref solution actually returns 1 too... So I guess you're not looking at the input that is making your solution fail.

  • Default User Avatar

    Thanks, it was kotlin though and didnt mutate the input. Just had this line for (i in arr) print("$i ") in to print out the input array elements

  • Custom User Avatar

    done

    edit: btw: don't forget to give the language when you open an issue (yeah, was JS, I know ;p )

  • Custom User Avatar

    pro tip: don't ever mutate the input... I'll update the tests, but keep in mind this is very bad practice.

  • Default User Avatar

    Why would 0 be expected for this input? Clearly the sign chanfes once

    testFixedZero
     
    > 4 1 0 -1 -2 -3 
    
    expected:<0> but was:<1>
    
  • Custom User Avatar
    1. Spoiler flag!
    2. Your solution is too slow. Statements "It passes all the tests" and "I get a timeout error" contradicts each other. You're not passing all the tests :P You're only passing all sample tests.
  • Custom User Avatar

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

  • Custom User Avatar

    Solved it bro :} Had to change my approach a little bit but at the end it was all worth it

  • Custom User Avatar

    You been unable to make your code work is not a kata issue. Please read this

    Java Completions 766

    Either solve it or forfeit it and see how to solve it.

  • Custom User Avatar

    Who is preparing those tests, my coding skills are not able to make this code more efficient. I mean, it is testing this code with Arrays that have 200000 items. Are you kidding me?

  • Custom User Avatar

    Popping out from front is of O(len(li)) complexity, and this time it is entirely useless.
    Why don't you use li[x] instead of li.pop(0)?

  • Custom User Avatar

    Due to use of pop, your solution is O(n^2) complexity and it's not performant enough. You need solution of O(n) complexity to pass this kata. Getting rid of pop and replacing it with something better should help, as some other user below had exactly the same problem (see https://www.codewars.com/kata/5ce399e0047a45001c853c2b/discuss/python#5f29e378ca407900248d73ba).

    Not a kata issue.

  • Custom User Avatar

    Let me repeat: range of vaules does not make any difference for this kata. you can have all 0s or all bazzillions, it does not matter. What matters is length of the input array, and not what is inside.

    4s for one array on your local machine is not enough. For Python, there are 5 cases with length of 100_000, and 5 cases woth length of 150_000 (and a couple of small cases). All of these ten cases run together have to run under 12 seconds. If your solution runs 4 seconds for one case, it won't manage to run 10 cases under 12 seconds.

  • Custom User Avatar

    @Blind4Basics

    Still doesnt make any sense.. they must have less than 0.1 Ghz (mathamaticly) for my code to make that bad of a result. I tested my code with 10 times more values and much bigger numbers then the actual tests do and even with value genration and printing i get 4 seconds. So how in the world should they get more than 12 seconds on a tenth of my values, that are also smaller?

  • Loading more items...