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.
You can also skip the "i < (int)strlen(full_name)" check because a pre-condition of the input is that a space must exist.
Maybe that was a joke only :)
This comment is hidden because it contains spoiler information about the solution
I do know regex :) What I didn't know was how to manage gsub with it and it is actually more difficult to read what is considered the top answer.
Nice combinations code.
The
copy
allocates heap space (strdup) which I want to free to avoid leakage, and so doesarr
(malloc), butchar *p
is just a pointer.Avoid recursion if you can.
This is hilarious and clever. Good job man.
Thanks, I learned several things from this solution :) Very clean.
I have a question though. Why do you need to free the copy variable but not variables like the char* p from the last iteration?
Not if the word chars are set to uniq before starting the count loop :)
Exactly..that is a good practice!
Mmmmmkay
wow, ur a genius!
This is not beautiful, it is a waste of processing resources. Sorting every word is awful. Just Hash it with O(n). Sorting is O(nlog(n))
It means the value will only be replaced if it is nil or false. (Correct me if I'm wrong please, I'm also new)
#Case 1:
a = 1
a ||= 10
print a #=> 1
#Case 2:
a = nil
a ||= 10
print a #=> 10
a||= 10 is logically equivalent to: a || a = 10
Let's understand that behaviour. When we put together many or's:
a || b || c || d, it will return true immediatly when the first true value is found.
So in the example above, if 'a' is true, then b, c and d WON'T be evaluated by the or operator.
The same happens here: a || a = 10.
if a is false (or nil) it will evaluate (a = 10) which then changes the value of a.
if a is true (or != nil), then (a = 10) WON'T be evaluated at all.
Loading more items...