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.
Im curious as to why we do not need to specify return "false" or "true" in this example?
Math is allowed, what you are getting is:
"Math::DomainError (Numerical argument is out of domain - "sqrt")"
you could use 'raise' to attend it or use logical expression to ensure the positive range of the number before use Math::sqrt
This comment is hidden because it contains spoiler information about the solution
Thanks for mentioning. I am new on this platform and didn't know the purpose of spoiler flag. Now I knnow. Thanks :)
Use spoiler flag, please.
This comment is hidden because it contains spoiler information about the solution
You get this error when you pass a negative value to Math.sqrt. You can't pass negative to it.
i agree, for example 1e16+1 returns true when it shouldn't
@Wei-LiangChew I'm a little late but then the while loop will iterate over with n - 1 = 8 (and so on)
hmm.. i kept getting sqrt error. not sure why. thought Math.sqrt isn't supported here.
This comment is hidden because it contains spoiler information about the solution
But what if the largest 5-digit number in
digits
doesn't start with 9?This is better than using array.shift because it leaves array unaltered.
Or do variables duplicate when put as arguments anyway?
I'm going to say the same thing others have said...
I don't think it makes sense to disallow the use of alias_method if they aren't creating a unique method. This asks users to create an alias for a method while preventing them from using best practices. For newer programmers this could potentially teach them bad practices or confuse them on what the best practices are.
I recommend allowing the use of alias_method if the goal is to have users alias a method, or have them add a simple method like String#first or String#last to return the first or last character.
This comment is hidden because it contains spoiler information about the solution
Loading more items...