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.
def find_first_sub_string(text: str, sub: str): index = text.find(sub) return index if index != -1 else None
def find_first_sub_string(text, sub):try: return text.index(sub)except: pass- def find_first_sub_string(text: str, sub: str):
- index = text.find(sub)
- return index if index != -1 else None
fun List<Int>.remove(vararg nums: Int) = filter { !nums.contains(it) }
def remove(integers, values):return list(filter(lambda x: x not in values,integers))- fun List<Int>.remove(vararg nums: Int) = filter { !nums.contains(it) }
import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test class KataTest { @Test fun sample() { assertEquals(listOf(2, 2, 4), listOf(1, 1, 2, 3, 1, 2, 3, 4).remove(1, 3)) assertEquals(listOf(5, 6, 7, 8), listOf(1, 1, 2, 3, 1, 2, 3, 4, 4, 3, 5, 6, 7, 2, 8).remove(1, 3, 4, 2)) assertEquals(listOf(8, 7, 6, 5, 1), listOf(8, 2, 7, 2, 3, 4, 6, 5, 4, 4, 1, 2, 3).remove(2, 4, 3)) } }
@test.describe("Basic Test Cases")def basic_test_cases():test.assert_equals(remove([], []), [])test.assert_equals(remove([1, 1, 3, 5, 7, 7, 7, 9, 10, 10], [1, 7, 9]), [3, 5, 10, 10])test.assert_equals(remove([1, 2, 3, 4, 5], [2, 4]), [1, 3, 5])- import org.junit.jupiter.api.Assertions.*
- import org.junit.jupiter.api.Test
- class KataTest {
- @Test
- fun sample() {
- assertEquals(listOf(2, 2, 4), listOf(1, 1, 2, 3, 1, 2, 3, 4).remove(1, 3))
- assertEquals(listOf(5, 6, 7, 8), listOf(1, 1, 2, 3, 1, 2, 3, 4, 4, 3, 5, 6, 7, 2, 8).remove(1, 3, 4, 2))
- assertEquals(listOf(8, 7, 6, 5, 1), listOf(8, 2, 7, 2, 3, 4, 6, 5, 4, 4, 1, 2, 3).remove(2, 4, 3))
- }
- }
Changes include fixing the accents feature to always include only one accent in a random position.
const accents = 'áéíóú', chars = 'abcdefghijklmnopqrstuvwxyz', a = 'bcdfghijklmnpqrstuvwxyzñ', b = 'aeilorsuy', c = 'aeioruhtlkkkkkkkkk', d = 'aeiourldns', e = 'abcdefyrnsltmpxizñ', f = 'aeiouylrf', g = 'aeiouhrlmns', h = 'aeiourlt', i = 'encstoadlmvzrgfrtpbkñ', j = 'uaoei', k = 'eiaolunyhsrw', l = 'eiayoug', m = 'aeiouypb', n = 'aeiouytgdcsn', o = 'abcdefnruplsmtzñ', p = 'rehaoilhtusp', q = 'u', r = 'aeioutymscdrnpb', s = 'etshaicupomlynk', t = 'eiraohuytlar', u = 'bcdfghnslrmtiaepzñ', v = 'eiaour', w = 'aeiouyhrnls', x = 'aeiouytcpl', y = 'elstacpnm', z = 'eaioyuz', ñ = 'aeiou'; function rng (doAccents = true, min = 4, max = 8, length = Math.floor(Math.random() * (max - min + 1)) + min, firstChar = chars[Math.floor(Math.random() * chars.length)]) { let out = []; for (let index = 0; index < length; index++) { if (index == 0) { out.push(firstChar); } else { out.push(eval(out[index-1])[Math.floor(Math.random() * eval(out[index-1]).length)]); } } if (doAccents) { out = addAccents(out); } if (out[out.length-1] == "ñ") { out.push(ñ[Math.floor(Math.random() * ñ.length)]); } return out.join(''); } function addAccents(arr) { let hasAccent = false; let outVowels = arr.filter(a => ñ.includes(a)); let lastVowel = outVowels[outVowels.length-1]; for (let i = 0; i < arr.length; i++) { let char = arr[i]; let newChar; if (Math.random() >= 0.5 && !hasAccent && ñ.includes(char)) { newChar = accents[ñ.indexOf(char)]; hasAccent = true; } else if (lastVowel == char && !hasAccent) { newChar = accents[ñ.indexOf(char)]; hasAccent = true; } arr[i] = newChar || char; } return arr; } for(let i = 0; i < 10; i++) { console.log(rng(true, 5, 6)); console.log(""); console.log(rng(false, 4, 8)); console.log(""); } // good names: garnguck, lemock, wemee, yermpoo, jelifyeshi, vazaji, zufazi, dupunt, trythluid /* more good names: elóra, yáddro, lezíe, janeño, bahúz, gouñuña, volgrad, flizz, tunck, vorag, sylem, kitala, vunos, jaith, qumor, henup, ornda, zilep, cantadu, gromu, lodley */
/*Changes include adding `accents` and the `ñ`.I also added `min` and `max` as parameters.*/- const accents = 'áéíóú',
- chars = 'abcdefghijklmnopqrstuvwxyz',
- a = 'bcdfghijklmnpqrstuvwxyzñ',
- b = 'aeilorsuy',
- c = 'aeioruhtlkkkkkkkkk',
- d = 'aeiourldns',
- e = 'abcdefyrnsltmpxizñ',
- f = 'aeiouylrf',
- g = 'aeiouhrlmns',
- h = 'aeiourlt',
- i = 'encstoadlmvzrgfrtpbkñ',
- j = 'uaoei',
- k = 'eiaolunyhsrw',
- l = 'eiayoug',
- m = 'aeiouypb',
- n = 'aeiouytgdcsn',
- o = 'abcdefnruplsmtzñ',
- p = 'rehaoilhtusp',
- q = 'u',
- r = 'aeioutymscdrnpb',
- s = 'etshaicupomlynk',
- t = 'eiraohuytlar',
- u = 'bcdfghnslrmtiaepzñ',
- v = 'eiaour',
- w = 'aeiouyhrnls',
- x = 'aeiouytcpl',
- y = 'elstacpnm',
- z = 'eaioyuz',
- ñ = 'aeiou';
- function rng (doAccents = true, min = 4, max = 8, length = Math.floor(Math.random() * (max - min + 1)) + min, firstChar = chars[Math.floor(Math.random() * chars.length)]) {
- let out = [];
- for (let index = 0; index < length; index++) {
- if (index == 0) {
- out.push(firstChar);
- } else {
- out.push(eval(out[index-1])[Math.floor(Math.random() * eval(out[index-1]).length)]);
- }
- }
- if (doAccents) {
let hasAccent = false;out = out.map(char => {let newChar;if (Math.floor(Math.random() * 10) >= 5) {newChar = ñ.includes(char) && !hasAccent ? accents[ñ.indexOf(char)] : char;hasAccent = true;}return newChar || char;});- out = addAccents(out);
- }
- if (out[out.length-1] == "ñ") {
- out.push(ñ[Math.floor(Math.random() * ñ.length)]);
- }
- return out.join('');
- }
- function addAccents(arr) {
- let hasAccent = false;
- let outVowels = arr.filter(a => ñ.includes(a));
- let lastVowel = outVowels[outVowels.length-1];
- for (let i = 0; i < arr.length; i++) {
- let char = arr[i];
- let newChar;
- if (Math.random() >= 0.5 && !hasAccent && ñ.includes(char)) {
- newChar = accents[ñ.indexOf(char)];
- hasAccent = true;
- } else if (lastVowel == char && !hasAccent) {
- newChar = accents[ñ.indexOf(char)];
- hasAccent = true;
- }
- arr[i] = newChar || char;
- }
- return arr;
- }
- for(let i = 0; i < 10; i++) {
- console.log(rng(true, 5, 6));
- console.log("");
- console.log(rng(false, 4, 8));
- console.log("");
- }
- // good names: garnguck, lemock, wemee, yermpoo, jelifyeshi, vazaji, zufazi, dupunt, trythluid
- /* more good names:
- elóra, yáddro, lezíe, janeño, bahúz, gouñuña,
- volgrad, flizz, tunck, vorag, sylem, kitala, vunos, jaith, qumor, henup, ornda, zilep, cantadu, gromu, lodley
- */