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.
The classical Fibonacci sequence is the special case with
a = [0, 1]
andb = [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 lastn
values,b
being the array/list of weights here. Naturally you then also needn
starting values, given asa
.Can somebody give a more detailed explanation about A and B arrays? Like [1, 1, 1] is not an initial Fib sequence and Fib(n) = Fib(n-1) + Fib(n-2) so there are 2 coefficients for B and no more. How are those correlate with each other?
Ahhahah
You are craze dude:) I would like to add you to my friends list:)
How can I make it more efficient?
Well, it is
O(n^2)
... so too slow ;)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 beO(n*3)
?3 sequential
O(n)
operations areO(n^3)
?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.
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.
This comment is hidden because it contains spoiler information about the solution
Blind4Basics, could you please navigate how the print console done. I came across with the same problem as this mister did.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Right, because you passed everything except
+0
itself ;-)Loading more items...