Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Does this sequence of directions lead you to the same position (starting point)? ;)
is it due to a loop that's causing the O(n^2) ?
do i have to make it O(n) ?
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).
Таже проблема. В этом то и сложность этого кода.
Нужно максимально его оптимизировать чтоб блина списка в 10**6 могла быстро решится.
Сам думаю над решением ;)
Your solution has a quite subtle bug.
Your code is wrong, and kata seems to be OK.
This comment is hidden because it contains spoiler information about the solution
If some tests fails it means your code is incorrect. What more could we say?? Please refer to the documentation mentioned above.
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 linen = n/2
and see if you notice something with the numbers that are appearing; why do you think this might cause an error?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.
Your code fails with inputs from 5 to 8 chars, figure out why now.