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.
import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; import java.util.Random; class SolutionTest { @Test void basicTest() { assertEquals("moqik", Kata.encode("abcde", "abcde")); assertEquals("abcde", Kata.decode("moqik", "abcde")); assertEquals("KMOUS", Kata.encode("ABCDE", "ABCDE")); assertEquals("ABCDE", Kata.decode("KMOUS", "ABCDE")); assertEquals("GIFUKTG", Kata.encode("DEARGOD", "FGH")); assertEquals("DEARGOD", Kata.decode("GIFUKTG", "FGH")); assertEquals("ikhwmvi", Kata.encode("deargod", "fgh")); assertEquals("deargod", Kata.decode("ikhwmvi", "fgh")); assertEquals("IQlOirL", Kata.encode("ALaBamA", "hoME")); assertEquals("ALaBamA", Kata.decode("IQlOirL", "hoME")); } @Test void fullTest() { assertEquals("CDEfA", Kata.encode("turbo", "TUXON")); assertEquals("turbo", Kata.decode("CDEfA", "TUXON")); assertEquals("skstzDvzwj", Kata.encode("helloworld", "afgh")); assertEquals("helloworld", Kata.decode("skstzDvzwj", "afgh")); assertEquals("JLN", Kata.encode("xyz", "ijklmn")); assertEquals("xyz", Kata.decode("JLN", "ijklmn")); assertEquals("riDREkxXFVygu", Kata.encode("hOmEsWeEtHoMe", "nOtSoSwEeT")); assertEquals("hOmEsWeEtHoMe", Kata.decode("riDREkxXFVygu", "nOtSoSwEeT")); assertEquals("qUlWuZXovQ", Kata.encode("gOdMoRNinG", "uSA")); assertEquals("gOdMoRNinG", Kata.decode("qUlWuZXovQ", "uSA")); assertEquals("byvNMwgiVt", Kata.encode("WonDErWaLl", "oASiS")); assertEquals("WonDErWaLl", Kata.decode("byvNMwgiVt", "oASiS")); assertEquals("MyynmpA", Kata.encode("Zumbido", "wow")); assertEquals("Zumbido", Kata.decode("MyynmpA", "wow")); assertEquals("BOywAJdrzSfbLMCuCnViNt", Kata.encode("wElovETerNaRyExpsaNdIj", "dAvID")); assertEquals("wElovETerNaRyExpsaNdIj", Kata.decode("BOywAJdrzSfbLMCuCnViNt", "dAvID")); } private String encode(String phrase, String key) { return ""; } private String decode(String phrase, String key) { return ""; } String generateString() { Random random = new Random(); byte[] buffer = new byte[random.nextInt(1501)]; random.nextBytes(buffer); return new String(buffer, java.nio.charset.Charset.forName("UTF-8")); } String generatePhrase() { return generateString(); } String generateKey() { return generateString(); } @RepeatedTest(100) void randomTest() { String phrase = generatePhrase(); String key = generateKey(); assertEquals(Kata.encode(phrase, key), encode(phrase, key)); assertEquals(Kata.decode(phrase, key), decode(phrase, key)); } }
- import static org.junit.jupiter.api.Assertions.assertEquals;
- import org.junit.jupiter.api.RepeatedTest;
- import org.junit.jupiter.api.Test;
- import java.util.Random;
- class SolutionTest {
- @Test
- void basicTest() {
- assertEquals("moqik", Kata.encode("abcde", "abcde"));
- assertEquals("abcde", Kata.decode("moqik", "abcde"));
- assertEquals("KMOUS", Kata.encode("ABCDE", "ABCDE"));
- assertEquals("ABCDE", Kata.decode("KMOUS", "ABCDE"));
- assertEquals("GIFUKTG", Kata.encode("DEARGOD", "FGH"));
- assertEquals("DEARGOD", Kata.decode("GIFUKTG", "FGH"));
- assertEquals("ikhwmvi", Kata.encode("deargod", "fgh"));
- assertEquals("deargod", Kata.decode("ikhwmvi", "fgh"));
- assertEquals("IQlOirL", Kata.encode("ALaBamA", "hoME"));
- assertEquals("ALaBamA", Kata.decode("IQlOirL", "hoME"));
- }
- @Test
- void fullTest() {
- assertEquals("CDEfA", Kata.encode("turbo", "TUXON"));
- assertEquals("turbo", Kata.decode("CDEfA", "TUXON"));
- assertEquals("skstzDvzwj", Kata.encode("helloworld", "afgh"));
- assertEquals("helloworld", Kata.decode("skstzDvzwj", "afgh"));
- assertEquals("JLN", Kata.encode("xyz", "ijklmn"));
- assertEquals("xyz", Kata.decode("JLN", "ijklmn"));
- assertEquals("riDREkxXFVygu", Kata.encode("hOmEsWeEtHoMe", "nOtSoSwEeT"));
- assertEquals("hOmEsWeEtHoMe", Kata.decode("riDREkxXFVygu", "nOtSoSwEeT"));
- assertEquals("qUlWuZXovQ", Kata.encode("gOdMoRNinG", "uSA"));
- assertEquals("gOdMoRNinG", Kata.decode("qUlWuZXovQ", "uSA"));
- assertEquals("byvNMwgiVt", Kata.encode("WonDErWaLl", "oASiS"));
- assertEquals("WonDErWaLl", Kata.decode("byvNMwgiVt", "oASiS"));
- assertEquals("MyynmpA", Kata.encode("Zumbido", "wow"));
- assertEquals("Zumbido", Kata.decode("MyynmpA", "wow"));
- assertEquals("BOywAJdrzSfbLMCuCnViNt", Kata.encode("wElovETerNaRyExpsaNdIj", "dAvID"));
- assertEquals("wElovETerNaRyExpsaNdIj", Kata.decode("BOywAJdrzSfbLMCuCnViNt", "dAvID"));
- }
- private String encode(String phrase, String key) {
- return "";
- }
- private String decode(String phrase, String key) {
- return "";
- }
- String generateString() {
- Random random = new Random();
- byte[] buffer = new byte[random.nextInt(1501)];
- random.nextBytes(buffer);
- return new String(buffer, java.nio.charset.Charset.forName("UTF-8"));
- }
- String generatePhrase() {
- return generateString();
- }
- String generateKey() {
- return generateString();
- }
- @RepeatedTest(100)
- void randomTest() {
- String phrase = generatePhrase();
- String key = generateKey();
- assertEquals(Kata.encode(phrase, key), encode(phrase, key));
- assertEquals(Kata.decode(phrase, key), decode(phrase, key));
- }
- }
public class AbbreviateTwoWords { public static String abbrevName(String name) { return "%s.%s".formatted(name.charAt(0), name.charAt(name.indexOf(" ") + 1)); } }
- public class AbbreviateTwoWords {
- public static String abbrevName(String name) {
return name.replaceAll("[^A-Z\\s]","").replaceAll("\\s",".");- return "%s.%s".formatted(name.charAt(0), name.charAt(name.indexOf(" ") + 1));
- }
- }
def satisfaction(participants, start_offset, tour_length): overlap = tour_length // start_offset firsts = overlap * ((overlap + 1) / 2) return participants * overlap - firsts
def satisfaction(n, x, t):start_times = [i * x for i in range(n)]finish_times = [(i * x) + t for i in range(n)]upset_factor = 0for i, writer in enumerate(finish_times):for j, others in enumerate(start_times):if others <= writer and i < j:upset_factor += 1print(start_times, finish_times)return upset_factor- def satisfaction(participants, start_offset, tour_length):
- overlap = tour_length // start_offset
- firsts = overlap * ((overlap + 1) / 2)
- return participants * overlap - firsts
import java.util.HashMap; import java.util.Map; public class Fibonacci { private static Map<Integer, Long> memoizationMap = new HashMap<>(); public static long calcFibo(int n) { //SECOND if (n <= 1) { return n; } if (memoizationMap.containsKey(n)) { return memoizationMap.get(n); } long fiboValue = calcFibo(n - 1) + calcFibo(n - 2); memoizationMap.put(n, fiboValue); return fiboValue; } }
- import java.util.HashMap;
- import java.util.Map;
- public class Fibonacci {
- private static Map<Integer, Long> memoizationMap = new HashMap<>();
- public static long calcFibo(int n) {
- //SECOND
- if (n <= 1) {
- return n;
- }
- if (memoizationMap.containsKey(n)) {
- return memoizationMap.get(n);
- }
- long fiboValue = calcFibo(n - 1) + calcFibo(n - 2);
- memoizationMap.put(n, fiboValue);
- return fiboValue;
- }
- }