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
.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.
Right, because you passed everything except
+0
itself ;-)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 anif
. Then rearrange the conditions (some is not even needed) anditem[0]!=0
will be alwaysTrue
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.
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.
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:
Print the input (add some chars before and after so you see spaces or other special char).
That's not the input of the tests that expect false. They have spaces and some other things.
Please count the sheep, starting from the right of the array and ignoring zero-bsed numbering.
Sheep number 2 is in danger as he is in front of the wolf.
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.
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 theTDD
box on your code, supplying your function with arguments.Attempt
will run hidden tests ( which you can view after youSubmit
) on your code. If you pass,Attempt
will change intoSubmit
.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! ^^
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...
Python translator didn't use the naming stated in the instructions,
a
->arr_val
b
->arr_unit
Loading more items...