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.
It was written 9 years ago.
I fear for you.
So lets go even further and add that 1 to arr[0], since it is also guaranteed not to be in the result.
God I'm so dumb..
@brendanvos
Your own solution also mutates the original list passed trough the function.
Out of curiousity i tried your solution in Pycharm. I stored [1, 1, 1] in a variable x, stored 10 in varuable y, called the function with (x, y) parameters and after requested a print(x). Both the print(function) and print(x) yielded the same result.
counter is useless, a simple input of (1011, 11) breaks your solution
I know the input string is rather short, but I think it can be easily done with less iteration with the use of dict or Counter. This would probably reduce algorithm complexity.
Sorry if I'm mistaken, but aren't you also mutating the input (signature) in your solution?
any
with a generator instead of a list (just remove the brackets) would be both efficient (returning True once a triple-double is found) AND easy to read. (expect for the str thing which could be done before)When I apply this solution as tribonacci([15, 16, 14], 3) I receive [15, 16, 14] but I had in one of the randomly generated tests, that the correct answer should be [45], which does not make sense. There should be a clearer specification to what the function should do for n in [1,2,3], I guess.
You don't remember correctly. Python lists are mutable. Mutable objects are pass by reference.
If you make changes to a list which was passed in as a parameter you WILL mutate the list for the caller.
No because python should be treating anything within a function as abstracted. If I remember correctly you'd have to declare it as a global variable
Thats cool :-)
Another solution, nothing special
lazy boi
Loading more items...