diff --git a/c/binary-search/src/binary_search.c b/c/binary-search/src/binary_search.c index b75ac9c..9720cf1 100644 --- a/c/binary-search/src/binary_search.c +++ b/c/binary-search/src/binary_search.c @@ -4,8 +4,7 @@ const int *binary_search(int v, const int *a, size_t size) { size_t lo, hi, i; - /* quickly exclude invalid/trivial results : - * NULL or empty array, value out of bounds + /* early exclude invalid/trivial result: NULL/empty array, value off bounds */ if (!size || !a || v < *a || v > *(a+size-1)) return NULL; @@ -22,7 +21,6 @@ const int *binary_search(int v, const int *a, size_t size) * https://github.com/braoult/exercism/blob/master/c/templates/GNUmakefile */ #ifdef UNIT_TEST -#include int main(int ac, char **av) { int arg=1, *res; diff --git a/c/binary-search/src/binary_search.h b/c/binary-search/src/binary_search.h index b89058a..af83713 100644 --- a/c/binary-search/src/binary_search.h +++ b/c/binary-search/src/binary_search.h @@ -12,6 +12,7 @@ const int *binary_search(int value, const int *arr, size_t length); #include #include #endif + #ifdef TESTALL #undef TEST_IGNORE #define TEST_IGNORE() {} diff --git a/c/hamming/src/hamming.c b/c/hamming/src/hamming.c index 144625a..c4f5301 100644 --- a/c/hamming/src/hamming.c +++ b/c/hamming/src/hamming.c @@ -1,14 +1,5 @@ #include "hamming.h" -/* Note: For explanation on section below, see 'GNUfilename' included in - * link below : - * https://exercism.io/my/solutions/103b2f7d92db42309c1988030f5202c7 - */ -#if defined UNIT_TEST || defined DEBUG -#include -#include -#endif - /* test does not include invalid input, but it should, as the subject is * about DNA sequence, not ASCII chars sequence :-) * exercism test needs only: @@ -16,22 +7,25 @@ */ #define V(p) (*(p)=='A' || *(p)=='C' || *(p)=='G' || *(p)=='T') -int compute(const char *lhs, const char *rhs) +int compute(const char *l, const char *r) { int res=0; - const char *l=lhs, *r=rhs; if (!l || !r) return -1; - for (; V(l) && V(r); ++l, ++r) { + for (; V(l) && V(r); ++l, ++r) if (*l != *r) res++; - } - return *r || *l? -1: res; + return *l || *r? -1: res; } +/* See GNUmakefile below for explanation + * https://github.com/braoult/exercism/blob/master/c/templates/GNUmakefile + */ +#if defined UNIT_TEST +#include +#include -#ifdef UNIT_TEST int main(int ac, char **av) { if (ac==3) { diff --git a/c/hamming/src/hamming.h b/c/hamming/src/hamming.h index 8e31f0b..52a42c1 100644 --- a/c/hamming/src/hamming.h +++ b/c/hamming/src/hamming.h @@ -3,9 +3,8 @@ int compute(const char *lhs, const char *rhs); -/* Note: For explanation on section below, see 'GNUfilename' included in - * link below : - * https://exercism.io/my/solutions/103b2f7d92db42309c1988030f5202c7 +/* See GNUmakefile below for explanation + * https://github.com/braoult/exercism/blob/master/c/templates/GNUmakefile */ #ifdef TESTALL #undef TEST_IGNORE