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.
#include <string> #include <string_view> std::string reverse_string(std::string_view word){ return {word.rbegin(), word.rend()}; }
- #include <string>
- #include <string_view>
using namespace std;string reverse_string(string_view word){- std::string reverse_string(std::string_view word){
- return {word.rbegin(), word.rend()};
- }
I was bored.
#include <stdlib.h> int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; } int unique_sum(const int arr[/*size*/], size_t size) { int r = 0; qsort(arr, size, sizeof(int), cmp); for (size_t i = 0; i < size; ) { if ((i == 0 || arr[i] != arr[i - 1]) && (i == size - 1 || arr[i] != arr[i + 1])) r += arr[i]; for (int v = arr[i]; i < size && arr[i] == v; i++); } return r; }
#include <bits/stdc++.h>using namespace std;int unique_sum(const vector<int>& n) {auto nums = n;sort(nums.begin(), nums.end(), [](int a, int b) {return a < b;});int sum = 0;for(size_t i = 0; i < nums.size(); i++) {if(nums[i] == nums[i+1] || nums[i] == nums[i-1]) {continue;} else {sum += nums[i];}- #include <stdlib.h>
- int cmp(const void *a, const void *b)
- {
- return *(int *)a - *(int *)b;
- }
- int unique_sum(const int arr[/*size*/], size_t size)
- {
- int r = 0;
- qsort(arr, size, sizeof(int), cmp);
- for (size_t i = 0; i < size; )
- {
- if ((i == 0 || arr[i] != arr[i - 1]) &&
- (i == size - 1 || arr[i] != arr[i + 1]))
- r += arr[i];
- for (int v = arr[i]; i < size && arr[i] == v; i++);
- }
return sum;- return r;
- }
// TODO: Replace examples and use TDD by writing your own tests. The code provided here is just a how-to example. #include <criterion/criterion.h> #include <stdlib.h> int unique_sum(const int[], size_t); Test(unique_sum_of_numbers, should_do_something) { cr_assert_eq(unique_sum((const int[]){1, 2, 3, 2}, 4), 4); cr_assert_eq(unique_sum((const int[]){1, 1, 2, 3}, 4), 5); cr_assert_eq(unique_sum((const int[]){-1, -1, 0, 1}, 4), 1); } Test(unique_sum_of_numbers, should_do_something_other) { cr_assert_eq(unique_sum((const int[]){}, 0), 0); cr_assert_eq(unique_sum((const int[]){5, 5, 5, 5}, 4), 0); cr_assert_eq(unique_sum((const int[]){10, 20, 30, 20, 10}, 5), 30); cr_assert_eq(unique_sum((const int[]){1, 2, 3, 4, 5}, 5), 15); cr_assert_eq(unique_sum((const int[]){-5, -5, 0, 5, 5}, 5), 0); cr_assert_eq(unique_sum((const int[]){-1, 2, -1, 3, 4, 2}, 6), 7); cr_assert_eq(unique_sum((const int[]){1, 2, 3, 4, 5, 1, 2, 3}, 8), 9); cr_assert_eq(unique_sum((const int[]){100, 200, 300, 300, 200, 100}, 6), 0); }
// TODO: Replace examples and use TDD by writing your own tests- // TODO: Replace examples and use TDD by writing your own tests. The code provided here is just a how-to example.
Describe(unique_sum_of_numbers)- #include <criterion/criterion.h>
- #include <stdlib.h>
- int unique_sum(const int[], size_t);
- Test(unique_sum_of_numbers, should_do_something)
- {
- cr_assert_eq(unique_sum((const int[]){1, 2, 3, 2}, 4), 4);
- cr_assert_eq(unique_sum((const int[]){1, 1, 2, 3}, 4), 5);
- cr_assert_eq(unique_sum((const int[]){-1, -1, 0, 1}, 4), 1);
- }
- Test(unique_sum_of_numbers, should_do_something_other)
- {
It(should_do_something){Assert::That(unique_sum({1,2,3,2}), Equals(4));Assert::That(unique_sum({1,1,2,3}), Equals(5));Assert::That(unique_sum({-1,-1,0,1}), Equals(1));};It(should_do_something_other){Assert::That(unique_sum({}), Equals(0));Assert::That(unique_sum({5, 5, 5, 5}), Equals(0));Assert::That(unique_sum({10, 20, 30, 20, 10}), Equals(30));Assert::That(unique_sum({1, 2, 3, 4, 5}), Equals(15));Assert::That(unique_sum({-5, -5, 0, 5, 5}), Equals(0));Assert::That(unique_sum({-1, 2, -1, 3, 4, 2}), Equals(7));Assert::That(unique_sum({1, 2, 3, 4, 5, 1, 2, 3}), Equals(9));Assert::That(unique_sum({100, 200, 300, 300, 200, 100}), Equals(0));}};- cr_assert_eq(unique_sum((const int[]){}, 0), 0);
- cr_assert_eq(unique_sum((const int[]){5, 5, 5, 5}, 4), 0);
- cr_assert_eq(unique_sum((const int[]){10, 20, 30, 20, 10}, 5), 30);
- cr_assert_eq(unique_sum((const int[]){1, 2, 3, 4, 5}, 5), 15);
- cr_assert_eq(unique_sum((const int[]){-5, -5, 0, 5, 5}, 5), 0);
- cr_assert_eq(unique_sum((const int[]){-1, 2, -1, 3, 4, 2}, 6), 7);
- cr_assert_eq(unique_sum((const int[]){1, 2, 3, 4, 5, 1, 2, 3}, 8), 9);
- cr_assert_eq(unique_sum((const int[]){100, 200, 300, 300, 200, 100}, 6), 0);
- }