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

  • Custom User Avatar

    general tip:

    your environment isn't CW's environment

    • maybe you processor is facter than the ones of the servers
    • in python, there are problems of performances with random value generation (related to the docker itself), meaning that'll slow even more the tests here.

    main idea to extract from this: don't rely on this kind of comparison. The only useful point of view for you is what's happening on CW.

    good luck ;)

  • Custom User Avatar

    @hobovsky This doesnt make any sense. I tested my code with randomly generated nums. 150000 nums between one hundred septenvigintillion and one hundred novemquinquagintillion. This took only 4 seconds with genrating the nums.

    Basically: It works, but on the site, it doesnt.

  • Custom User Avatar
  • Custom User Avatar

    You could also find some hints in comments below, for example this one: https://www.codewars.com/kata/5ce399e0047a45001c853c2b/discuss#5f29266f664ae7001042a4d7

  • Custom User Avatar

    It depends on language, but values do not mattr much for this kata, array length is much more important and arrays can be long. Like, 100_000 elements.
    Try to generate a couple of arrays with gradually increasing length, let's say 100 lements, 1000 elements, 10_000 and 100_000 elements and see if your solution can handle these.

    In Python, there are 5 tests where max array length can go up to 150_000.

  • Custom User Avatar

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

  • Custom User Avatar

    l2.pop(0) is potentially expensive, because it modifies the whole list by removing first element from it. It depends how exactly it is implemented, but in most obvious approach, removing first element is costly, because all elements have to be moved one step to the left to fill the resulting "hole". Solution with pop can effectively have complexity of O(n^2). OTOH, l2[i] simply reads ith value without modifying anything. It does not incur any additional cost. That's why this solution seems to be faster, its complexity is O(n).

  • Default User Avatar

    Attempting to solve this in Kotlin and getting the time out error :(

  • Default User Avatar

    I am not the Scala translator but the tests in Scala are less difficult than in other languages (because Scala as all languages derived from Java is rather slow at CW). I tried many solutions and several run under 10500 ms. 65 guys passed the kata so I think it is doable. If you want to use recursion think of import scala.annotation.tailrec.
    Note: the only difficulty of the kata is about performance...

  • Default User Avatar

    thanks you @hobovsky probably right

  • Custom User Avatar

    Now I look at that, I think I am wrong about timeout. I believe your recursive solution fails with stack overflow error, that's why it does not show anything in output panel.

  • Custom User Avatar

    Your solution does not pass all the tests, it times out crashes. Strange thing is, output panel does not tell you that :(

    EDIT: I think my suspicion of timeout was incorrect.

    In Scala, there are 75 tests and they are unfortunately running in time close to timeout, so if your solution is for some reason not close to "intended approach", you risk running out of time.

    Your solution passes ~65 tests, so you are probably rather good with your general idea, unfortunately I am afraid you will have to tweak it somehow to squeeze these additional 10 test cases. You might try some approach without recursion, if you can come up with any.

    I will think about raising an issue to decrease amount of test cases to allow other valid approaches.

  • Default User Avatar

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