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
Mathematics
Algorithms
Logic
Numbers
Code
Diff
  • def prime_checker(n):
        if n in [2, 3, 5]:
            return True
        elif n % 2 == 0 or n % 3 == 0 or n % 5 == 0:
            return False
        
        a = int(n ** 0.5 / 30)
        b = [7, 11, 13, 17, 19, 23, 29, 31]
        
        for i in [30 * j for j in range(a + 1)]:
            if True in [n % (i + q) == 0 for q in b if i + q is not n]:
                return False
        return True 
    • """
    • https://en.wikipedia.org/wiki/Primality_test
    • This one has lesser tests or usage of % operator.
    • An alternative using primality mod 30 = 2 * 3 * 5 instead of 6 = 2 * 3
    • """
    • def prime_checker(n):
    • if n in [2, 3, 5]:
    • return True
    • elif n % 2 == 0 or n % 3 == 0 or n % 5 == 0:
    • return False
    • a = int(n ** 0.5 / 30)
    • b = [7, 11, 13, 17, 19, 23, 29, 31]
    • for i in [30 * j for j in range(a + 1)]:
    • if True in [n % (i + q) == 0 for q in b if i + q is not n]:
    • return False
    • return True
Code
Diff
  • def find_max(arr):
        return sorted(arr)[-1]
    • def find_max(arr):
    • return 0
    • return sorted(arr)[-1]
Code
Diff
  • const returnhundred = _ => [_=+!_+[+!!_]]*_
    • function returnhundred() {
    • return 10 ** 2;
    • }
    • const returnhundred = _ => [_=+!_+[+!!_]]*_
Code
Diff
  • async function a() {
      return 'ok'
    }
    
    async function b() {
      try{
        const resolve = await a();
        console.log(resolve);
      }catch(reject){
        console.log(err);
      }
    }
    • function a() {
    • return new Promise(function (resolve, reject) {
    • resolve('ok');
    • });
    • async function a() {
    • return 'ok'
    • }
    • function b() {
    • a().then(function(res) {
    • console.log(res);
    • }).catch(function(err) {
    • async function b() {
    • try{
    • const resolve = await a();
    • console.log(resolve);
    • }catch(reject){
    • console.log(err);
    • })
    • }
    • }
Code
Diff
  • const main = () => {
    
      let a = [1, 2, 3];
      
      let b = [4, 5, 6];
      
      let c = [7, 8, 9];
    
      // converter para ES6
      var d =  [...a, ...b, ...c];
      
      return d.join(',');
    }
    • const main = () => {
    • let a = [1, 2, 3];
    • let b = [4, 5, 6];
    • let c = [7, 8, 9];
    • // converter para ES6
    • var d = a.concat(b).concat(c);
    • var d = [...a, ...b, ...c];
    • return d.join(',');
    • }
Code
Diff
  • // reescreva usando ES6
    
    var prop = 'myProp';
    
    var obj = {
      [prop]: 123,
      myFunc() {
        return this[prop];
      } 
    };
    
    • // reescreva usando ES6
    • var prop = 'myProp';
    • var obj = {
    • myFunc: function() {
    • [prop]: 123,
    • myFunc() {
    • return this[prop];
    • }
    • };
    • obj[prop] = 123;
Code
Diff
  • var title = 'UOL - O melhor conteúdo';
    
    var share = {
      fb: {
        title: {title}
      },
      twitter: {
        tweet: {title}
      }
    };
    • var title = 'UOL - O melhor conteúdo';
    • var share = {
    • fb: {
    • title: title
    • title: {title}
    • },
    • twitter: {
    • tweet: title
    • tweet: {title}
    • }
    • };
Code
Diff
  • let results = [
      {materia: {conteudo: {titulo: 'São Paulo'}}, tags: [1, 2, 3]},
      {materia: {conteudo: {}}, tags: [3, 2]},
      {materia: {conteudo: {titulo: 'Rio de Janeiro'}}, tags: [3, 2]},
    ];
    
    for (const {materia: {conteudo: {titulo = 'Brasil'}}} of results){ 
    
    console.log(titulo);
    }
    • let results = [
    • {materia: {conteudo: {titulo: 'São Paulo'}}, tags: [1, 2, 3]},
    • {materia: {conteudo: {}}, tags: [3, 2]},
    • {materia: {conteudo: {titulo: 'Rio de Janeiro'}}, tags: [3, 2]},
    • ];
    • for (const result of results) {
    • let titulo = result.materia.conteudo.titulo || 'Brasil';
    • console.log(titulo);
    • for (const {materia: {conteudo: {titulo = 'Brasil'}}} of results){
    • console.log(titulo);
    • }
Code
Diff
  • var bg = 'gray';
    
    var css = `
      <style>
      body {
        background:${bg};
        color: black;
       }
      </style>`;
      
    
    • var bg = 'gray';
    • var css = '' +
    • '<style>' +
    • 'body {' +
    • ' background: '+ bg + ';' +
    • ' color: black;'
    • '}' +
    • '</style>';
    • var css = `
    • <style>
    • body {
    • background:${bg};
    • color: black;
    • }
    • </style>`;
Code
Diff
  • // reescreva em ES6
    function main(a, b = 2, c = 3) {
        
        return a * b * c;
    }
    • // reescreva em ES6
    • function main(a, b, c) {
    • if (typeof b == 'undefined')
    • b = 2;
    • if (typeof c == 'undefined')
    • c = 3
    • function main(a, b = 2, c = 3) {
    • return a * b * c;
    • }