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.
for
50
, your code will returnXXXXX
(5X
s, each representing a value of10
) whilst the correct output should beL
. The same also applies for other interval checking points greater than 10.I am reading about regular expressions now, it starting to make sense. Thanks!
This is the syntax of regular expressions, you have to search about this topic if you don't know it.
This comment is hidden because it contains spoiler information about the solution
This will add a space before every capital letter regardless of whether it is part of a camelcased word...
I benchmarked it and found it to be at least twice as slow as the ternary implemenatation. It looks nice though.
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.
It's a question of what's more idiomatic. See Avdi Grimm's master work: Confident Ruby
Which version of Ruby do you have locally? My Ruby 2.0.0 return
false
for negative numbers.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.
The description specifies: "Input will always be a non-negative integer."
Don't think this solution is correct: when n and m are both negative, this solution will give you the positive result, when 0 should be returned.
This comment is hidden because it contains spoiler information about the solution
This is my favorite answer, grats for making me laugh :D