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 fibonacci(b):
        if b in [0, 1]: return b 
        return fibonacci(b-1) + fibonacci(b-2)
    
    • def fibonacci(b):
    • if b == 0:
    • return 0
    • elif b == 1:
    • return 1
    • else :
    • return fibonacci(b-1) + fibonacci(b-2)
    • if b in [0, 1]: return b
    • return fibonacci(b-1) + fibonacci(b-2)
Code
Diff
  • const linkedList = {
      list: {},
      addToList: {},
    };
    • const linkedList = {};
    • const linkedList = {
    • list: {},
    • addToList: {},
    • };
  • Adds a second argument to generateComment, seed, which allows for deterministic strings
  • Adds a few tests (still bad coverage)
Code
Diff
  • const generateComment = (array = [], seed) =>
      (seed => array.map((each, ii) => each[seed[ii]]).join` `)
        (seed
          ? seed.split`.`.map(Number)
          : array.map(ii => Math.round(Math.random() * (ii.length - 1))))
            
    const dictionary = [
      ['hi,', 'hello,', 'hey,'],
      ['how are'],
      ['you', 'ya'],
      ['doing', 'going'],
      ['?', '?!', '']
    ]
    
    console.log(generateComment(dictionary))
    console.log(generateComment(dictionary, '2.0.1.0.1'))
    • const generateComment = array => array.map(x=>x[Math.floor(Math.random() * x.length)]).join` `
    • const generateComment = (array = [], seed) =>
    • (seed => array.map((each, ii) => each[seed[ii]]).join` `)
    • (seed
    • ? seed.split`.`.map(Number)
    • : array.map(ii => Math.round(Math.random() * (ii.length - 1))))
    • const dictionary = [
    • ['hi,', 'hello,', 'hey,'],
    • ['how are'],
    • ['you', 'ya'],
    • ['doing', 'going'],
    • ['?', '?!', '']
    • ]
    • // console.log(generateComment([['hi,', 'hello,', 'hey,'], ['how are'], ['you', 'ya'], ['doing', 'going'], ['?', '?!', '']]));
    • console.log(generateComment(dictionary))
    • console.log(generateComment(dictionary, '2.0.1.0.1'))
Fundamentals
Arrays
Data Types
Code
Diff
  • const sum = array => array.reduce((total, n) => total + n, 0);
    • const getSum = array => array.reduce((acc, i) => acc + i)
    • const sum = array => array.reduce((total, n) => total + n, 0);
Code
Diff
  • function a(){
      // We shall remove the following solution when publish as KATA
      static $poi = null;
      if ($poi) return $poi->create();
      $poi = new class {
         public function create() {
            return new static();
         }
      };
      return $poi->create();
    }
    • function a(){
    • // We shall remove the following solution when publish as KATA
    • static $poi = null;
    • if ($poi) return $poi->create();
    • $poi = new class {
    • public function create() {
    • return new static();
    • }
    • };
    • return $poi->create();
    • }
Bugs

One line version with error output as lambda (analog of arrow function in Python) looks like this.

Code
Diff
  • div = lambda num1, num2 : print("Division failed: division by zero") if num2 == 0 else print("Division failed: integers and floats accepted only") if not(isinstance(num1, (int, float)) and isinstance(num2, (int, float))) else num1 / num2
    
    • let divide = (num1, num2) => num2 === 0 ? console.log("Division failed: division by zero") : !(num1 === +num1 && num2 === +num2) ? console.log("Division failed: integers and floats accepted only") : num1/num2
    • div = lambda num1, num2 : print("Division failed: division by zero") if num2 == 0 else print("Division failed: integers and floats accepted only") if not(isinstance(num1, (int, float)) and isinstance(num2, (int, float))) else num1 / num2