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
  • // 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;
Fundamentals
Arrays
Data Types
Code
Diff
  • var sum=0;
    const getSum = (array) => {sum=0; array.every( Sum = (curvalue) => {sum+=curvalue; return true; }); return sum;}
    • function getSum(array) {
    • //your code
    • }
    • var sum=0;
    • const getSum = (array) => {sum=0; array.every( Sum = (curvalue) => {sum+=curvalue; return true; }); return sum;}

I wonder what this does?

(defn goes-before? [val1 val2] (<= val1 val2))

;; bubble: list of number -> list of number
;; This was originally racket code, 
;; so it used 'car' and 'cdr' instead of 'first' and 'next'
;; Why can't clojure keep my theming?
(defn bubble [tanks]
  ;; I'm using nested if statements here because I want to use let
  (if (or (nil? tanks) (nil? (next tanks)))
      (cons tanks '(false))
      (let* [truck (first tanks) convoy (next tanks) jeep (first convoy)]
         (if (goes-before? truck jeep)
           (let [debrief (bubble convoy)] (cons (cons truck (first debrief)) (next debrief)))
           (cons (cons jeep (first (bubble (cons truck (next convoy))))) '(true))
           )
        )
      )
  )
  
  ;; bubble-sort: list of number -> list of number
(defn bubble-sort [l]
  (let [bubbly (bubble l)]
    (if (first (next bubbly))
        (bubble-sort (first bubbly))
        (first bubbly)
        )))
        
  (prn (bubble-sort (list 5 4 3 2 1)))
Code
Diff
  • function dumbRockPaperScissors(player1, player2) {
     
      if((player1 === 'Rock' && player2 === 'Scissors') || 
         (player1 === 'Scissors' && player2 === 'Paper') ||  
         (player1 === 'Paper' && player2 === 'Rock')){ return 'Player 1 wins';}
      else if((player2 === 'Rock' && player1 === 'Scissors') || 
         (player2 === 'Scissors' && player1 === 'Paper') ||  
         (player2 === 'Paper' && player1 === 'Rock')){ return 'Player 2 wins';}
      else{
        
        return 'Draw';
      }
      
      
    }
    • function dumbRockPaperScissors(player1, player2) {
    • if(player1 == "Rock" && player2 == "Paper"){
    • return "Player 2 wins";
    • }
    • else if(player1 == "Rock" && player2 == "Scissors" ){
    • return "Player 1 wins";
    • }
    • else if(player1 == "Scissors" && player2 == "Paper"){
    • return "Player 1 wins";
    • }
    • else if(player1 == "Scissors" && player2 == "Rock"){
    • return "Player 2 wins";
    • }
    • else if(player1 == "Paper" && player2 == "Scissors"){
    • return "Player 2 wins";
    • }
    • else if(player1 == "Paper" && player2 == "Rock"){
    • return "Player 1 wins";
    • if((player1 === 'Rock' && player2 === 'Scissors') ||
    • (player1 === 'Scissors' && player2 === 'Paper') ||
    • (player1 === 'Paper' && player2 === 'Rock')){ return 'Player 1 wins';}
    • else if((player2 === 'Rock' && player1 === 'Scissors') ||
    • (player2 === 'Scissors' && player1 === 'Paper') ||
    • (player2 === 'Paper' && player1 === 'Rock')){ return 'Player 2 wins';}
    • else{
    • return 'Draw';
    • }
    • else if(player1 == "Paper" && player2 == "Paper"){
    • return "Draw";
    • }
    • else if(player1 == "Rock" && player2 == "Rock"){
    • return "Draw";
    • }
    • else if(player1 == "Scissors" && player2 == "Scissors"){
    • return "Draw";
    • }
    • }

The algorithm works with constant complexity O(n), memory is limited to O(n)

Code
Diff
  • const firstNonRepeatingCharacter = (str) => {
        let stack = str.split('')
        let deletedChars = ''
        let result;
        
        while(stack.length > 0) {
          let current = stack.shift()
          
          if (!deletedChars.includes(current)) {
              if (!stack.includes(current)) {
                  result = current;
                  break;
              } else {
                  deletedChars += current;
              }
          }
        }
        
        return result || null;
    };
    • const firstNonRepeatingCharacter = (str) => {
    • for (let i = 0; i < str.length; i++) {
    • let seenDuplicate = false;
    • for (let j = 0; j < str.length; j++) {
    • if (str[i] === str[j] && i !== j) {
    • seenDuplicate = true;
    • break;
    • }
    • }
    • if (!seenDuplicate) {
    • return str[i];
    • }
    • let stack = str.split('')
    • let deletedChars = ''
    • let result;
    • while(stack.length > 0) {
    • let current = stack.shift()
    • if (!deletedChars.includes(current)) {
    • if (!stack.includes(current)) {
    • result = current;
    • break;
    • } else {
    • deletedChars += current;
    • }
    • }
    • }
    • return null; // return null if no unique character is found
    • return result || null;
    • };
Code
Diff
  • //  def multiply (a,b):
    //      return a * b
    
    const multiply = (a, b) => a * b;
    
    • // # def multiply (a,b):
    • // # return a * b
    • // def multiply (a,b):
    • // return a * b
    • multiply = (a, b) => a * b;
    • const multiply = (a, b) => a * b;
Code
Diff
  • const cinema_auditorium = (spisok2D,ryad)=> {
     return spisok2D[ryad].reduce((sum, el)=> sum+el)   
    }
    • const cinema_auditorium = (spisok2D,ryad)=> {
    • console.log(spisok2D,ryad)
    • return 3
    • return spisok2D[ryad].reduce((sum, el)=> sum+el)
    • }

Силиванова

Code
Diff
  • function нечетное(число) {
      if (число%2!=0){
        return true
      }
      else {
        return false
      }
    }
    function sumNechet(a, b) {
      let sum=0
      for(slag=a;slag<=b;slag++){
        if (нечетное(slag)){
        sum+=slag
      }
      }
      
      return (sum)          
    }
    • function sumNechet(a, b) {
    • }
    • function нечетное(число) {
    • if (число%2!=0){
    • return true
    • }
    • else {
    • return false
    • }
    • }
    • function sumNechet(a, b) {
    • let sum=0
    • for(slag=a;slag<=b;slag++){
    • if (нечетное(slag)){
    • sum+=slag
    • }
    • }
    • return (sum)
    • }