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.
I think this is a great Kata. It's dealing with a baffeling and somewhat mysterious sequence. There is for sure a recursive solution to calculate the numbers. But it should be considered, that recursive solutions could be waaayyy too slow calculating higher numbers...
This is kind of verbose!
What regex is made for: to shorten such code.
Yeah, me too, I definitely join the downvoters.
But it's something like a valid solution.
Oh, my, as I expectd, my brute force approach for JavaScript passed the first tests but timed out on the 'attempt'-tests. So I have to try something different... Maybe with a generator-function.
OK, solved!
In my C solution the test always says:
Test Crashed Caught unexpected signal: 6
Completed in 0.0000ms
STDERR
setup.c:46:21: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
for (int i = 0; i < strlen(str); i++) {
~ ^ ~~~~~~~~~~~
1 warning generated.
munmap_chunk(): invalid pointer
On my computer it runs perfectly, also with valgrind, I cannot find a memory leak.
I checked the mallocs, but everything seems to be fine. Maybe I should increase/decrease the size of the allocated memory?
For the C solution I'd definitely rank it as 6 kyu.