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.
Ok, sorry I didn't know...
You should not post solutions, otherwise anyone can see them.
I have added the spoiler flag to your comment.
This comment is hidden because it contains spoiler information about the solution
after seven years from your comment, I could't agree more! the zip got me!
no matter how hard I'm thinking to shrink my code, there's always people who has one line solutions.
Kudos tho because I'm learning either way!
I was actually tempted to use the isqrt function from the math module but didn't later do it before figuring out a better solution
I really love this approach to the solution.
It combines the comparison of the number with -1 with the square root of the number into a logic statement
This comment is hidden because it contains spoiler information about the solution
regex wizzards in the house
zero readability. cramming too much functionality into a single line can sometimes sacrifice readability and maintainability of the code. 0/10
So that it will work for
n=0
testThank you. I realized what the problem was. Instead of return in the function I used print...
The fact that your solution worked on your machine does not mean it was correct. Maybe your solution is wrong, and tests on your machine are also wrong and they cannot find the problem? Maybe you do something wrong on your machine, or differently than Codewars does?
"works on my machine" does not prove correctness of anything. To complete a kata on Codewars, it needs to pass tests on Codewars. Working on your machine does not help, and does not prove anything.
Everything worked in my code editor, and this is not the first time...
Your solution with
import math.sqrt
was not accepted most probably because it was not correct. We cannot tell why it was not correct, because we don't know what it was, but most probably it has nothing to do with importing themath.sqrt
, but rather using it incorrectly.Loading more items...