Ad
  • Default User Avatar

    Does this sequence of directions lead you to the same position (starting point)? ;)

  • Custom User Avatar

    is it due to a loop that's causing the O(n^2) ?
    do i have to make it O(n) ?

  • Custom User Avatar

    You don't have to worry about the size of the input (don't need to test if the length of the list is less than 1M).

    The problem is that your solution takes a time that is proportional to the length of the list squared. It means that if the input is 3 times as big, your solution will run 9 (3x3) times longer. The goal of this kata is to find a way to code a solution that takes a time proportional to the length of the argument.

    With big words, your solution currently runs in O(n^2) and you have to make it run in O(n).

  • Default User Avatar

    Таже проблема. В этом то и сложность этого кода.
    Нужно максимально его оптимизировать чтоб блина списка в 10**6 могла быстро решится.
    Сам думаю над решением ;)

  • Custom User Avatar

    Your solution has a quite subtle bug.
    Your code is wrong, and kata seems to be OK.

  • Custom User Avatar

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

  • Custom User Avatar

    If some tests fails it means your code is incorrect. What more could we say?? Please refer to the documentation mentioned above.

  • Default User Avatar

    What he means is that it's better if you give some context, like what language you are using/things you have tried to troubleshoot yourself etc. before asking for help (otherwise it looks like you have given up after your first small problem, which means people won't really want to help you).

    I looked at your code: here's what you should do - add print(n) at the start of your program, this will allow you to see which input is causing your problems. In this case you will see that it is for input value of n = 73567465519280238573 (a big number)

    To troubleshoot what is going wrong, I will give you a hint: add print(n) just after your line n = n/2 and see if you notice something with the numbers that are appearing; why do you think this might cause an error?

  • Custom User Avatar

    See there for a general help, and how to ask for help more efficiently: https://docs.codewars.com/training/troubleshooting/

    You give almost no information, so it's very hard to say anything.

  • Custom User Avatar

    Your code fails with inputs from 5 to 8 chars, figure out why now.