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 it's because basic tests are hardcoded, the strings are contained in the program, while all the other tests' input lives in local variables on the stack which gets filled with random data each time, then used, then abandoned. You're modifying the program's own memory (data segment, IINM, or maybe rodata, I dunno). Here is a problem: the word
"commas"
appears in the basic tests more than once. (edit: so does"javascript"
)The compiler is only going to store that string one time in one place and refer to it multiple times, but you can only "use" it and pass the first time. After that, it's been mangled, and nothing matches, and you are out of luck.Many tests on this site will fail because of people modifying the inputs, even when they aren't declared
const
. If you do seeconst
, don't try it, don't even hope to get away with changing things behind it. If you really feel you need to modify input data (and this time you really don't), just take a copy of it usingstrdup()
and work on that. I tried removing theconst
qualifiers from my function, and basic tests keep working because I only count the letters.P.S. if you use
strdup()
don't forget tofree()
that variable when you're done.