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.
This comment is hidden because it contains spoiler information about the solution
Recursion can be fast enough if you cache the results.
The problem may be that when you allocate your char array with
c = (char *)malloc(sizeof(char) * (i + 1));
, you are not setting the last elementc[i]
to 0 (or'\0'
). Remember thatmalloc
does not initialize any memory, it only allocates it (butcalloc
will initialize to 0). This can cause a problem withstrcmp
since it compares the strings up until it reaches 0 on one or both of them.incredible
lol what
This is not a well tested kata. Some of the test cases are off by one in Racket. It seems like some expect the population to be greater or equal than the desired one, but some expect it to be greater.
This shouldn't be a solution, although it's very clever how you gamed the system.