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.
No, by entire array I meant that if the array has length n, his code runs through 2n elements on average.
I presume you took the time results provided by the test cases which deviate in general, that way the claim can be made either way. If you just run both versions in a properly timed environment you get mine to be about 3x faster, regardless of whether they lists are fully randomized or worst case samples.
He traverses the entire array at most one time.
This solution is faster than your solution: random tests in 390ms vs 450ms.
Can confirm that caps lock on european keyboard behaves like permanently pressing shift key. This means caps lock and shift key at once negate each other.
The description should say "caps lock only matters to letters". From the tests we only know it doesn't apply to numbers but have to find out ourselves about special characters like comma or apostrophe.
I laughed too hard at this my face hurts
In short, importing the sqrt certainly doesn't benefit from being in the function. :P
Interestingly, the site groups code that imports outside the function with code that imports inside the function. Check the variations and you'll see. It just happened to choose the one with the import inside as the canonical version for some reason.
For the most part, you are right. PEP 8 recommends only importing at the top of a file. Doing otherwise makes debugging much harder. However, technically there might be very rare situations where you might want to import inside of a function -- if only that function ever needs that module, the function is rarely or never called, and you don't want to pollute the global namespace, or if you want to defer and handle ImportError exceptions on a case-by-case basis, or you want to do some sort of conditional import depending on the passed parameters. Some others say they use it to resolve circular dependency issues, but that can almost always be avoided with a little restructuring of the affected files without the overhead a local import would involve.
you wouldn't import inside a function.
you can elaborate on that using the discussions thread instead of writing the code :D
bad testing
just loop over it without using a comp .-.
golfing works here but you can't use len() for every single iteration..
cheap
regex and still chaotic, ugh.
cheat :P
This comment is hidden because it contains spoiler information about the solution
Loading more items...