Start a new Kumite
AllAgda (Beta)BF (Beta)CCFML (Beta)ClojureCOBOL (Beta)CoffeeScriptCommonLisp (Beta)CoqC++CrystalC#D (Beta)DartElixirElm (Beta)Erlang (Beta)Factor (Beta)Forth (Beta)Fortran (Beta)F#GoGroovyHaskellHaxe (Beta)Idris (Beta)JavaJavaScriptJulia (Beta)Kotlinλ Calculus (Beta)LeanLuaNASMNim (Beta)Objective-C (Beta)OCaml (Beta)Pascal (Beta)Perl (Beta)PHPPowerShell (Beta)Prolog (Beta)PureScript (Beta)PythonR (Beta)RacketRaku (Beta)Reason (Beta)RISC-V (Beta)RubyRustScalaShellSolidity (Beta)SQLSwiftTypeScriptVB (Beta)
Show only mine

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.

Ad
Ad
Code
Diff
  • 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
Code
Diff
  • power = pow
    • power=lambda n,p,r=1:power(n,p-1,r*n)if p else r
    • power = pow
Code
Diff
  • 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) }
Code
Diff
  • export let flip_the_number = (x:number) => +[...""+x].reverse().join('')
    • export let flip_the_number = (x:number) => +[...`${x}`].reverse().join('')
    • export let flip_the_number = (x:number) => +[...""+x].reverse().join('')

Changes include fixing the accents feature to always include only one accent in a random position.

Code
Diff
  • 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
    • */