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.
Holy cow. I had no idea about this "and" behavior. Unlike some languages where logical operators always return True or False, Python's "and" returns the last evaluated operand!
This doesn't even work for large odd lists...
ok now i can sleep peacefully thankyou
This comment is hidden because it contains spoiler information about the solution
No, 117 = 3313 and 117 ** 0.5 is about 10, so if you break the while loop, you won't find 13! But if you want to find out is a number prime, that will help.
While the code is short, it runs through the entire list twice! :Urgh:
It is neither clever nor a best practice.
very inefficient
If you do p.append([m,1]) break the while loop when i ** 2 > m it will be faster.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
What should I be surprised about? In this solution, we iterate the entire list twice, while on average we only need to check half of the list to find an outlier. We should consider general complexity, not the special case when the list has 3 elements.
Have you benchmarked it? If you haven't, you should and might be surprised.
This solution is 4 times slower than it could be
Man, thx for showing me the other way to solve this problem. The way you use enumerate is genius!
how is this voted best practices? It iterates through the entire list twice, when in reality most circumstances you don't even have to make one complete iteration of the list. Also, the list is renamed to int which is also pretty bad practice.
Loading more items...