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 do. Do you want to try to find it first? If not I'll tell you now...
Don't forget the spoiler flag, please.
This comment is hidden because it contains spoiler information about the solution
Few people are refactoring; Good Job
Isn't programing for speed (O(n) time vs O(n Squared) time) a best practice???
Your solution has a potential crash bug in it; the same one that mine has.
Do you see it? (The Kata Test can't catch it that's why ours passed)
No falut in the Kata; it could not have caught it...
My "solution" has a severe bug, do you see it?
Assume! That sounds reall good.
I'm very impressed with your turn around time and dedication!
This translation was done when I had just started translating to C. I can't recall if
C18
was available then or only3.6
. When I became aware ofC18
I began translating with that as my standard. So, seeing what's up with this kata suggests I go check out my other old translations as I have with this one. Today I gave this translation the royal treatment: by adding theNULL
check you mentioned, providing better feedback for failed code, and (of course) eliminating all of those 32 warnings.Minor issue since as you pointed out you can still do the Kata...
If you look at the test code:
#define ASSERT_ARR_EQ(expected, submitted, sz)
if(sz == 0 && submitted != NULL)
{ free(submitted); submitted = NULL;
cr_assert(0, "n == 0, should return NULL\n"); }
for(size_t i=0; i<sz; i++)
if(submitted[i] != expected[i])
cr_assert(0,
"Incorrect value at index %i: %lld should equal %lld\n",
i, submitted[i], expected[i]);
cr_assert(1);
It does not NULL check submitted if sz != 0...
Actually when I simply return NULL there does appear to be a testing error:
Test Results:
Sample_Tests
should_pass_all_the_tests_provided
Test Crashed
Caught unexpected signal: SIGSEGV (11). Invalid memory access.
Should the Test crash?
NULL is supposed to mean 'empty array' in this test.
Shouldn't it be reported as a wrong return value as opposed to the test crashing?
Ah yes, Correct.
I guess my mind set is warings == errors
I don't let warnings stand because they either contain important info or obscure other important info when out of hand...
You mean compilation warnings ?
Other than a shitton of warnings, kata works fine in C.
Loading more items...