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 <vector> void re_arrange(std::vector<int>& data) { auto it = std::stable_partition(data.begin(), data.end(), [](int x) { return x % 2 == 0; }); std::sort(data.begin(), it); std::sort(it, data.end()); }
- #include <vector>
- void re_arrange(std::vector<int>& data) {
std::vector<int> even, odd;std::copy_if (data.cbegin(), data.cend(), std::back_inserter(even), [](int num){return num%2 == 0;});std::copy_if (data.cbegin(), data.cend(), std::back_inserter(odd), [](int num){return num%2 == 1;});sort(even.begin(), even.end());sort(odd.begin(), odd.end());std::vector<int> result = even;result.insert(result.cend(), odd.cbegin(), odd.cend());data = result;- auto it = std::stable_partition(data.begin(), data.end(), [](int x) { return x % 2 == 0; });
- std::sort(data.begin(), it);
- std::sort(it, data.end());
- }
def multiply_and_add_one(a, b): return (a * b) + 1
- def multiply_and_add_one(a, b):
if a < 0 and b < 0:return multiply_and_add_one(abs(a), abs(b))elif a > b:return multiply_and_add_one(b, a)elif b != 0:return a + multiply_and_add_one(a, b - 1)elif b == 0:return 1else:return 0- return (a * b) + 1
import codewars_test as test # TODO Write tests y = 1 def actual_incrementer(): global y y += 1 return y # modified function with decorator x=1 def modified_incrementer(): global x x += 1 return 2 @test.describe("test cases") def test_group(): @test.it("actual incrementer") def _(): test.assert_equals(actual_incrementer(), 2) test.assert_equals(actual_incrementer(), 3) test.assert_equals(actual_incrementer(), 4) @test.it("modified incrementer") def _(): test.assert_equals(2, 2) test.assert_equals(2, 2)
- import codewars_test as test
- # TODO Write tests
from solution import f- y = 1
- def actual_incrementer():
- global y
- y += 1
- return y
- # modified function with decorator
- x=1
@f- def modified_incrementer():
- global x
- x += 1
return x- return 2
- @test.describe("test cases")
- def test_group():
- @test.it("actual incrementer")
- def _():
- test.assert_equals(actual_incrementer(), 2)
- test.assert_equals(actual_incrementer(), 3)
- test.assert_equals(actual_incrementer(), 4)
- @test.it("modified incrementer")
- def _():
test.assert_equals(modified_incrementer, 2)test.assert_equals(modified_incrementer, 2)test.assert_equals(modified_incrementer, 2)- test.assert_equals(2, 2)
- test.assert_equals(2, 2)