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.
Unnecessary to iterate over all letters of s2.
'All triangles will be right isoceles.' from the Kata description.
Nice extension to a general scenario though.
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.
This assumes that the triangle is isoceles, which might not be the case.
All tests are but maybe we could have a triange like:
Which would result in area of "1" but this solution does not.
I believe there is an issue with the card on the fixed test for Python. My code passed all the random tests, but I would get an index error on the fixed tests. I entered this at the top of my code and everything passed:
i dont thik there is better solution then this one
This comment is hidden because it contains spoiler information about the solution
Question: My code (python) passes all the 100 "correctness" tests but times out during the 100 "performance" tests. I'm using numpy to count all the nxn subarrarys that have only 1's and storing the results in a dictionary. When there are less than 4 nxn arrays with only 1's, my program returns the result. I can't see how my solution can be optimized without doing some sort of mathematical approach to narrow down the subarrays that need checking. Is a mathematical approach necessary? Any suggestions would be greatly appreciated.
This is because you are trying to do the calculation of 'd' within the loop- you have to do it after 'a' has been populated completely.
Also, you have a typo when checking for v==8, a[i] == ...
I have the same question. If the input is the PIN number as a string, then my code should work.
I had the same issue. I was calculating based on the largest. Good question and explnation.
This comment is hidden because it contains spoiler information about the solution
Thanks so much for the reply. I got it to work. The fact that someone like you would respond so quickly to someone so new at coding is why I love this community.
Loading more items...