Ad
  • Custom User Avatar

    The classical Fibonacci sequence is the special case with a = [0, 1] and b = [1, 1]. This kata asks for generalized sequences where the next value isn't just the sume of the last two values but a weighted sum of the last n values, b being the array/list of weights here. Naturally you then also need n starting values, given as a.

  • Custom User Avatar

    I don't think so.
    But there is a loop in a loop, so I think it's O(n^2).
    pop(index(max(...))) would probably be O(n*3)? :laughing:

  • Custom User Avatar

    pop(index(max(...))) -> this is O(n^3)

    3 sequential O(n) operations are O(n^3)?

  • Custom User Avatar

    Also, if there actually is an issue, then it would be either a translator, the author of the kata, or a power user (in most cases) that would fix it. I don't see why an admin would need to do it.

  • Custom User Avatar

    Hi,

    First, admins won't change a kata because there is a problem in your code... ;o

    Second, time out is generally caused either by infinite loops or really inefficient code. Yours belongs to the second category: lst.pop(lst.index(max(lst))) -> this is O(n^3), in terms of time complexity. You can hardly do worse, in that kind of task x).

    And lastly, if you get one fail among 2000, maybe there is an actual issue somewhere, but then, how do you want anyone to catch what it is if you don't provide the actual case? ;p (input + assertion message)

    cheers

    PS: if you don't know anything to time complexity, do some googling about it.

  • Custom User Avatar

    Right, because you passed everything except +0 itself ;-)

  • Custom User Avatar

    Check again the link I posted, it's not easy to read Python code without indentation. Your code has several problems inside the for loop, why are you using a while loop there? Use an if. Then rearrange the conditions (some is not even needed) and item[0]!=0 will be always True when item is a string. I've managed to make corrections to your code and made it work, so you should be able to do it too.
    Also, your last if is an antipattern, just return the comparison.

  • Custom User Avatar

    Post it here marking your post as having spoiler content and to increase the readability of comments or descriptions, see this page in the github wiki.

  • Custom User Avatar

    The kata is not bugged. It's a problem with your code, you didn't say which language you're trying, but if it is Python:

    Python Completions 5069

    Print the input (add some chars before and after so you see spaces or other special char).

  • Custom User Avatar

    That's not the input of the tests that expect false. They have spaces and some other things.

  • Default User Avatar

    Please count the sheep, starting from the right of the array and ignoring zero-bsed numbering.

    [sheep, sheep, sheep, sheep, sheep, wolf, sheep, sheep] -front->     You are here at the front of the queue of sheep
       7      6      5      4      3            2      1
    

    Sheep number 2 is in danger as he is in front of the wolf.

  • Custom User Avatar

    I think ValentinLevalet meant there are no sample tests for javascript, only the TDD skeleton (that should be completed to be useful).
    AFAIK AhtyTheCoder only used Python and has already solved this kata.

  • Custom User Avatar

    Yeah, that won't ever work. Because you can't remove the Submit Tests.

    Define a function in the Solution box. Run Sample Tests will run the tests in the TDD box on your code, supplying your function with arguments. Attempt will run hidden tests ( which you can view after you Submit ) on your code. If you pass, Attempt will change into Submit. Submit and you get to see everybody's solutions ( and the tests, and - if you fork a solution - Preloaded ).

    ( It helps if you mention which language you're using. Hopefully the above is generic enough. )

    Happy coding! ^^

  • Custom User Avatar

    You could test with some values like in the example [1, 2, 3, 4, 5, 6] for numbers and 2 for divisor.

    I succeeded by removing all the code in the Test Driven Development, apparently here the Solution can work without that...

  • Custom User Avatar

    Python translator didn't use the naming stated in the instructions,

    a -> arr_val

    b -> arr_unit

  • Loading more items...