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.
Approved
Scala translation
CoffeeScript translation
Approved
python new test framework
Thanks for the hint. I was allocating with malloc. I switched to calloc and the bug was fixed.
Your code does not NULL-terminate your output, so that causes undefined behavior outside of your function.
I think there is a problem with the random tests. I'm coding in C. Take a look at what I got.
n = 9
Submitted: dokuz
Expected: �adokuz
Any idea about what is going on here?
Done for Python.
thank u sd8c8v8, very cool
Probably just because I'm a golf noob, but I thought this was harder than 6 kyu (a 5, IMO). Fun challenge; thanks!
You are returning pointers to string literals, which are not heap-allocated and typically reside in the
.rodata
segment of your program. Thus, they cannot befree()
'd. When the tests suite tries to free your pointer, it does not point to a heap address, which the OS detects as a memory violation and crashes your program. You need to dynamically allocate memory on the heap withmalloc()
,calloc()
orrealloc()
.There is a widely respected convention on Codewars as to wether pointers to string literals are accepted as a return value or not (if there are no precisions in the description): if the return type of the function is
char*
, your function is supposed to return a heap-allocated, free-able string; if the return type isconst char*
, you can return string literals and the tests suite will not try to free it.As a side note, since string literals are typically stored in read-only memory (
.rodata
segment), trying to modify them leads to a crash:This is not the case if you use them as an array initializer :
This comment is hidden because it contains spoiler information about the solution
Python new test framework should be used (Refer this & this for more detail)
Ruby 3.0 should be enabled (Refer this & this for more detail)
The "encoded" example is incorrect:
"ArNran u rstm5twob e ePb"
(24 characters even though it's a 5×5 square).It should be
"ArNran u rstm5twob e ePb"
instead - note the extra space after "wob".Edit: it looks like the markdown parser is collapsing whitespace even within the code blocks, hence the error. Seems to work when using a non-breaking space character, " ".
Loading more items...