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
  • {
      function todo() {
          return 'Walk';
        }
      
        // reescrever em ES6
        {
      
          function todo() {
            return 'Run';
          }
      
        }
    }
    
    • function todo() {
    • return 'Walk';
    • }
    • // reescrever em ES6
    • (function() {
    • {
    • function todo() {
    • return 'Run';
    • }
    • })();
    • return 'Walk';
    • }
    • // reescrever em ES6
    • {
    • function todo() {
    • return 'Run';
    • }
    • }
    • }
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
  • 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';
    • 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
  • // Exercício 1
    const titulo = "UOL - O melhor conteúdo";
    
    
    // Exercício 2
    const tags = []
    
    tags.push(...['A', 'B']);
    
    
    // Exercício 3
    let descricao = "Em 1999";
    
    descricao += " em São Paulo";
    
    
    // Exercício 4
    const materia = {titulo: "Barão de Limeira"};
    
    materia.titulo = "Alameda " + materia.titulo;
    
    
    // Exercício 5
    for (let i = 10; i--;) {
      console.log(i);
    }
    
    
    // Exercício 6
    for (const tag of ['A', 'B']) {
      console.log(tag);
    }
    
    
    // Exercício 7
    for (var j = [].length; j--;) {}
    
    if (j === -1) {
      console.log('Não encontrei');
    }
    
    
    // Exercício 8
    let a = 123;
    
    {
      a *= 2;
    }
    
    console.log(a);
    
    
    // Exercício 9
    let state = 'active';
    
    function stop() {
      state = 'paused';
    }
    
    stop();
    
    
    // Exercício 10
    const TRUE = !0;
    • // Exercício 1
    • var titulo = "UOL - O melhor conteúdo";
    • const titulo = "UOL - O melhor conteúdo";
    • // Exercício 2
    • var tags = []
    • const tags = []
    • tags.push(...['A', 'B']);
    • // Exercício 3
    • var descricao = "Em 1999";
    • let descricao = "Em 1999";
    • descricao += " em São Paulo";
    • // Exercício 4
    • var materia = {titulo: "Barão de Limeira"};
    • const materia = {titulo: "Barão de Limeira"};
    • materia.titulo = "Alameda " + materia.titulo;
    • // Exercício 5
    • for (var i = 10; i--;) {
    • for (let i = 10; i--;) {
    • console.log(i);
    • }
    • // Exercício 6
    • for (var tag of ['A', 'B']) {
    • for (const tag of ['A', 'B']) {
    • console.log(tag);
    • }
    • // Exercício 7
    • for (var j = [].length; j--;) {}
    • if (j === -1) {
    • console.log('Não encontrei');
    • }
    • // Exercício 8
    • var a = 123;
    • let a = 123;
    • {
    • a *= 2;
    • }
    • console.log(a);
    • // Exercício 9
    • var state = 'active';
    • let state = 'active';
    • function stop() {
    • state = 'paused';
    • }
    • stop();
    • // Exercício 10
    • var TRUE = !0;
    • const TRUE = !0;

"Hello Python!" script.

print "Hello Python!"
Code
Diff
  • console.log((n=>["Almost there","yuh gotta wait a little"][+(n>3)])(90))
    • let distance = 90; // try changing this value to test different outputs
    • output = distance < 3 ? "Almost there": "yuh gotta wait a little"
    • console.log(output);
    • console.log((n=>["Almost there","yuh gotta wait a little"][+(n>3)])(90))
Code
Diff
  • // патриотическая задача 1 22ФПИ1 Власова
    _ = (число_1, число_2, число_3) =>
    число_1>число_2?
      число_1>число_3?
      число_1:число_3
      :число_2>число_3?
      число_2:число_3
    • // патриотическая задача 1
    • _ = () =>
    • // патриотическая задача 1 22ФПИ1 Власова
    • _ = (число_1, число_2, число_3) =>
    • число_1>число_2?
    • число_1>число_3?
    • число_1:число_3
    • :число_2>число_3?
    • число_2:число_3
Code
Diff
  • //патриотическая задача 2 22фпи1 Зубарева Макеева
    _ = (_1,_3) => (_3==_1)?_1:_3+_(_1,_3-1);
    • _ = (_1,_2) =>
    • //патриотическая задача 2 22фпи1 Зубарева Макеева
    • _ = (_1,_3) => (_3==_1)?_1:_3+_(_1,_3-1);

Safe version because of not using an eval, yet still prone to errors like DivizionByZeroExcpetion or KeyError

Code
Diff
  • from operator import add, sub, mul, truediv
    
    def calculator(a, b, operator):
        return {'+': add, '-': sub, '*': mul, '/': truediv}[operator](a, b)
    
    • from operator import add, sub, mul, truediv
    • def calculator(a, b, operator):
    • if not isinstance(a, (int, float)) or not isinstance(b, (int, float)):
    • return "Operands must be numbers"
    • operations = {
    • '+': lambda x, y: x + y,
    • '-': lambda x, y: x - y,
    • '*': lambda x, y: x * y,
    • '/': lambda x, y: x / y if y != 0 else "Cannot divide by zero"
    • }
    • if operator not in operations:
    • return "Invalid operator"
    • return operations[operator](a, b)
    • return {'+': add, '-': sub, '*': mul, '/': truediv}[operator](a, b)