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.
It's easier ;-)
d=lambda x:d(x//10)+x%10 if x>9 else x a=lambda m,s,p:d(m)<d(s)+d(p)d,a=lambda n:sum(int(c) for c in str(n)),lambda m,s,p:d(m)<d(s)+d(p)- d=lambda x:d(x//10)+x%10 if x>9 else x
- a=lambda m,s,p:d(m)<d(s)+d(p)
Test.expect(not a(27,3,1)); Test.expect(a(33,9,7)); Test.expect(a(50,26,24)); Test.expect(not a(47,25,4)); Test.expect(a(47,25,5)); Test.expect(not a(107,4,22)); Test.expect(a(106,4,22));- Test.expect(not a(27,3,1));
- Test.expect(a(33,9,7));
Test.expect(a(50,26,24));- Test.expect(a(50,26,24));
- Test.expect(not a(47,25,4));
- Test.expect(a(47,25,5));
- Test.expect(not a(107,4,22));
- Test.expect(a(106,4,22));
#include <criterion/criterion.h> #include <stdlib.h> #include <mcheck.h> char *my_strdup_1(const char *str); char *my_strdup_2(const char *str); Test(my_strdup_1, should_work_correctly) { static const char str[] = "Qwerty"; char *const res = my_strdup_1(str); cr_assert_str_eq(res, str); free(res); } Test(my_strdup_2, should_work_correctly) { static const char str[] = "Qwerty"; char *const res = my_strdup_2(str); cr_assert_str_eq(res, str); free(res); } __attribute__((constructor(101))) static void init() { mcheck(NULL); }- #include <criterion/criterion.h>
- #include <stdlib.h>
- #include <mcheck.h>
- char *my_strdup_1(const char *str);
- char *my_strdup_2(const char *str);
- Test(my_strdup_1, should_work_correctly) {
- static const char str[] = "Qwerty";
- char *const res = my_strdup_1(str);
- cr_assert_str_eq(res, str);
- free(res);
- }
- Test(my_strdup_2, should_work_correctly) {
- static const char str[] = "Qwerty";
- char *const res = my_strdup_2(str);
- cr_assert_str_eq(res, str);
- free(res);
- }
- __attribute__((constructor(101))) static void init() {
- mcheck(NULL);
- }
This is a code golf site now.
s=lambda l:l if len(l)<3else[l[0],l[-1]]+s(l[1:-1])def special_sort(list):r = []l = len(list)for i in range(l // 2 + 1):if i == 0 or (i == l // 2 and not l % 2):r.append(list[i])else: r.extend([list[-i], list[i]])return r- s=lambda l:l if len(l)<3else[l[0],l[-1]]+s(l[1:-1])
test.assert_equals(s([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]), [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) test.assert_equals(s([0, 1, 2, 3, 4, 5, 6, 7, 8]), [0, 8, 1, 7, 2, 6, 3, 5, 4])# TODO: Replace examples and use TDD development by writing your own tests# These are some of the methods available:# test.expect(boolean, [optional] message)test.assert_equals(special_sort([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]), [0, 9, 1, 8, 2, 7, 3, 6, 4, 5])test.assert_equals(special_sort([0, 1, 2, 3, 4, 5, 6, 7, 8]), [0, 8, 1, 7, 2, 6, 3, 5, 4])# test.assert_not_equals(actual, expected, [optional] message)# You can use Test.describe and Test.it to write BDD style test groupings- test.assert_equals(s([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]), [0, 9, 1, 8, 2, 7, 3, 6, 4, 5])
- test.assert_equals(s([0, 1, 2, 3, 4, 5, 6, 7, 8]), [0, 8, 1, 7, 2, 6, 3, 5, 4])
class Kata{ public static Boolean verifySum(String nameOne, String nameTwo) { int sumOfNames = 0; if (nameOne == null || nameTwo == null) { return null; } for (char ch : nameOne.toCharArray()){ sumOfNames += ch; } for (char ch : nameTwo.toCharArray()){ sumOfNames -= ch; } return sumOfNames == 0; } }- class Kata{
public static String verifySum(String nameOne, String nameTwo) {int[] sumOfNames = new int[]{0, 0};- public static Boolean verifySum(String nameOne, String nameTwo) {
- int sumOfNames = 0;
- if (nameOne == null || nameTwo == null) {
return "NULL";- return null;
- }
for (int i = 0; i < nameOne.length(); i++){sumOfNames[0] += nameOne.charAt(i);- for (char ch : nameOne.toCharArray()){
- sumOfNames += ch;
- }
for (int i = 0; i < nameTwo.length(); i++){sumOfNames[1] += nameTwo.charAt(i);- for (char ch : nameTwo.toCharArray()){
- sumOfNames -= ch;
- }
return sumOfNames[0] == sumOfNames[1] ? "TRUE" : "FALSE";- return sumOfNames == 0;
- }
- }
import org.junit.Test; import static org.junit.Assert.assertEquals; import org.junit.runners.JUnit4; public class SolutionTest { @Test public void testName() { assertEquals(false, Kata.verifySum("Sebastian", "Patricia")); assertEquals(true, Kata.verifySum("Anna", "Nana")); assertEquals(null, Kata.verifySum("John", null)); } }- import org.junit.Test;
- import static org.junit.Assert.assertEquals;
- import org.junit.runners.JUnit4;
- public class SolutionTest {
- @Test
- public void testName() {
assertEquals("FALSE", Kata.verifySum("Sebastian", "Patricia"));assertEquals("TRUE", Kata.verifySum("Anna", "Nana"));assertEquals("NULL", Kata.verifySum("John", null));- assertEquals(false, Kata.verifySum("Sebastian", "Patricia"));
- assertEquals(true, Kata.verifySum("Anna", "Nana"));
- assertEquals(null, Kata.verifySum("John", null));
- }
- }