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.
Agreed. Codewars uses Ruby 2.1.6, and this issue is not fixed until 2.2
The random tests fail because although
-3
should return false, Ruby 2.1.6sees it as
-3.abs.prime?
, where "self" is just3
.I filed a suggestion on this kata... IDK how much the author can do about this.
Which version of Ruby do you have locally? My Ruby 2.0.0 return
false
for negative numbers.Why wouldn't you allow alias or
alias_method
. It's like you're trying to teach people how to do it the wrong way just to sate your desire to show how to reopen a class and define a method. The exercise could have been adjusted to require some additional behavior above just redirecting to an existing method wholesale.This seemed like a really dull, aimless exercise.
This didn't work for me because many of the tests are random and Ruby's stdlib Prime will return true for negative numbers when the absolute value is prime, but the test is not expecting it.
I'd personally wrap the
n * c
in parantheses, since a lot of people don't have order of operation precedence memorized and it could save them a few seconds reading it.