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.
In Elixir,
""
and0
are considered truthy values.Is this idiomatic Elixir way?
Learned something new on the
gsub
block method!sum += value
is not needed,sum + value
is enough, since the value will be returned tosum
in each iterationDoesn't need
+=
,s + $dict[ch]
would be enough. :)Can someone explain this one?
Nice one!
This comment is hidden because it contains spoiler information about the solution
No reason. They are the same.
Here's the bench mark for both methods.
Which version of Ruby do you have locally? My Ruby 2.0.0 return
false
for negative numbers.Didn't see your JS translation show up?
This comment is hidden because it contains spoiler information about the solution
It's using a recursive function. It passes two arguments,
n
anda
, anda
has a default value[]
.In Ruby,
collatz n, a = []
is same ascollatz(n, a = [])
, the parentesis can be omitted.Try to debug in your local ide to see if it works. If it does work then might be some codewars issue.
Loading more items...