Kumite (ko͞omiˌtā) is the practice of taking techniques learned from Kata and applying them through the act of freestyle sparring.
You can create a new kumite by providing some initial code and optionally some test cases. From there other warriors can spar with you, by enhancing, refactoring and translating your code. There is no limit to how many warriors you can spar with.
A great use for kumite is to begin an idea for a kata as one. You can collaborate with other code warriors until you have it right, then you can convert it to a kata.
no need to assign strlen
to a seperate variable, saved some cycles.
#include <stdlib.h> #include <string.h> #include <ctype.h> char *fun(const char *input) { char *result = malloc(strlen(input) + 1); char *p = result; while (*p++ = toupper(*input++)); return result; }
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
char *fun(const char *input) {size_t len = strlen(input);char *result = malloc(len + 1);char *p = result;while ((*p++ = toupper(*input++)));return result;- char *fun(const char *input)
- {
- char *result = malloc(strlen(input) + 1);
- char *p = result;
- while (*p++ = toupper(*input++));
- return result;
- }
_Bool above_two(int *arg) { return *arg > 2 ? 1 : (*arg = 3, 0); }
template<typename T>bool above_two(T& arg){static_assert(std::is_arithmetic<T>::value, "arg must be a arithmetic type");if(arg <= T(2)){arg = T(3);}return true;- _Bool above_two(int *arg)
- {
- return *arg > 2 ? 1 : (*arg = 3, 0);
- }
#include <criterion/criterion.h> _Bool above_two(int *arg); void tester(int arg) { cr_assert_eq(arg > 2, above_two(&arg)); cr_assert(arg > 2); } Test(example, test_case) { tester(0); tester(1); tester(2); tester(3); tester(4); tester(5); tester(6); tester(7); tester(8); tester(9); tester(10); }
template<typename T>void tester(T arg){if(arg > 2){auto expected = arg;Assert::That(above_two(arg), Equals(true));Assert::That(arg, Equals(expected));}else{Assert::That(above_two(arg), Equals(true));Assert::That(arg, Is().GreaterThan(2));}- #include <criterion/criterion.h>
- _Bool above_two(int *arg);
- void tester(int arg)
- {
- cr_assert_eq(arg > 2, above_two(&arg));
- cr_assert(arg > 2);
- }
Describe(example)- Test(example, test_case)
- {
It(test_case_int){tester(0);tester(1);tester(2);tester(3);tester(4);tester(5);tester(6);tester(7);tester(8);tester(9);tester(10);}It(test_case_double){tester(0.0);tester(1.0);tester(2.0);tester(3.0);tester(4.0);tester(5.0);tester(6.0);tester(7.0);tester(8.0);tester(9.0);tester(10.0);}};- tester(0);
- tester(1);
- tester(2);
- tester(3);
- tester(4);
- tester(5);
- tester(6);
- tester(7);
- tester(8);
- tester(9);
- tester(10);
- }