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.
Ruby example added to description.
In fact, you don't even need it for this particular method. #select will work directly on the Range object.
A small tip - it may look less natural but it is worth using equals the oposite way to avoid NullPointerException:
"John Smith".equals(name)
.Your are calculating the same thing multiple times and it could be made just once:
word.chars.sort.join
.Ruby version lacks an example output.
In ruby version of this kata the first test is incorrect:
Test.assert_equals(song_decoder("ABWUBWUBC"), "A B C","WUB should be replaced by 1 space");
A
andB
cannot be recognized as separate words. Correct output forABWUBWUBC
should beAB C
, but considering this test's comment it should probably look like this:Test.assert_equals(song_decoder("AWUBBWUBC"), "A B C","WUB should be replaced by 1 space");
Notice
WUB
between each word inAWUBBWUBC
.perfect! Thanks!
I guess
to_a
makes your solution use a lot of memory (for big numbers), which is unneeded.