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 sum n
    	(0..n).reduce(:+)
    end
    • def sum n
    • n == 1 ? 1 : n + sum(n - 1)
    • (0..n).reduce(:+)
    • end
Code
Diff
  • # What are all the ways to output a string in Ruby?
    def hello_ruby
      greet = "Hello Ruby!"
    
      print           greet, "\n"
      puts            greet
      print           greet, "\n"
      puts            greet
      $stdout.write   greet + "\n"
      $stdout.puts    greet
      $stdout.print   greet, "\n"
      $stdout <<      greet + "\n"
      (greet+"\n").chars {|c| print c}
    end
    • # What are all the ways to output a string in Ruby?
    • def hello_ruby
    • greet = "Hello Ruby!"
    • print greet, "\n"
    • puts greet
    • print "#{greet}
    • "
    • puts "Hello Ruby!"
    • print greet, "
    • "
    • puts greet
    • $stdout.write greet + "\n"
    • $stdout.puts greet
    • $stdout.print greet, "\n"
    • $stdout << greet + "\n"
    • (greet+"
    • ").each_char {|c| print c}
    • (greet+"
    • ").chars {|c| print c}
    • end
Code
Diff
  • def id_matrix(size):
         return [[i == j for j in range(size)] for i in range(size)]
    
    • def id_matrix(size):
    • return [[1 if i == j else 0 for j in range(size)] for i in range(size)]
    • return [[i == j for j in range(size)] for i in range(size)]
Code
Diff
  • def  getVillianName(birthday):
        return '{} {}'.format(  FIRSTNAME[birthday.strftime("%B")], 
                                LASTNAME[birthday.strftime("%d")[1]])
    
    • def getVillianName(birthday):
    • result = ""
    • result = FIRSTNAME[birthday.strftime("%B")] + " "
    • result += LASTNAME[birthday.strftime("%d")[1]]
    • return result
    • return '{} {}'.format( FIRSTNAME[birthday.strftime("%B")],
    • LASTNAME[birthday.strftime("%d")[1]])
Code
Diff
  • import itertools
    
    
    def eratosthenes():
        # From Coobook recipies
        # Credits to: Credit: David Eppstein, Tim Peters, Alex Martelli,
        # Wim Stolker, Kazuo Moriwaka, Hallvard Furuseth, Pierre Denis,
        # Tobias Klausmann, David Lees, Raymond Hettinger
        D = {}
        yield 2
        for q in itertools.islice(itertools.count(3), 0, None, 2):
            p = D.pop(q, None)
            if p is None:
                D[q * q] = q
                yield q
            else:
                x = p + q
                while x in D or not (x & 1):
                    x += p
                D[x] = p
    
    
    def count_primes(limit):
        count = 0
        for prime in eratosthenes():
            if prime > limit:
                return count
            count += 1
    • import itertools
    • from itertools import *
    • def eratosthenes():
    • #From Coobook recipies
    • #Credits to: Credit: David Eppstein, Tim Peters, Alex Martelli,
    • #Wim Stolker, Kazuo Moriwaka, Hallvard Furuseth, Pierre Denis,
    • #Tobias Klausmann, David Lees, Raymond Hettinger
    • D = { }
    • # From Coobook recipies
    • # Credits to: Credit: David Eppstein, Tim Peters, Alex Martelli,
    • # Wim Stolker, Kazuo Moriwaka, Hallvard Furuseth, Pierre Denis,
    • # Tobias Klausmann, David Lees, Raymond Hettinger
    • D = {}
    • yield 2
    • for q in itertools.islice(itertools.count(3), 0, None, 2):
    • p = D.pop(q, None)
    • if p is None:
    • D[q*q] = q
    • D[q * q] = q
    • yield q
    • else:
    • x = p + q
    • while x in D or not (x&1):
    • while x in D or not (x & 1):
    • x += p
    • D[x] = p
    • def count_primes(limit):
    • count = 0
    • for prime in eratosthenes():
    • if prime > limit: return count
    • if prime > limit:
    • return count
    • count += 1
Code
Diff
  • using System;
    using System.Linq;  
    
    public class Kata
        {
          private const int monmeValue = 60;
        
            public static int[] PurchaseTofu(int cost, string box)
            {
                string[] boxSplited = box.Split(' ');
                
                var monCount = boxSplited.Count(x => x == "mon");//one foreach will be faster than this 2 lines but this is easier to read
                var monmeCount = boxSplited.Count(x => x == "monme");
    
                var totalValue = monCount + (monmeCount * monmeValue);
    
                int monmeCounter = Math.Min(cost / monmeValue, monmeCount);
                cost -= monmeCounter * monmeValue;
    
                return (monCount < cost) ? 
                  new[] { 0 } : //leaving the market
                  new[] { monCount, monmeCount, totalValue, monmeCounter + cost };
            }
        }
    • using System;
    • using System.Linq;
    • public class Kata
    • {
    • private const int monmeValue = 60;
    • public static int[] PurchaseTofu(int cost, string box)
    • {
    • string[] boxSplited = box.Split(' ');
    • string[] boxSplited = box.Split(' ');
    • var monCount = boxSplited.Count(x => x == "mon");//one foreach will be faster than this 2 lines but this is easier to read
    • var monmeCount = boxSplited.Count(x => x == "monme");
    • var totalValue = monCount + (monmeCount * 60);
    • var totalValue = monCount + (monmeCount * monmeValue);
    • int monmeCounter = cost / 60;
    • if (monmeCounter > monmeCount)
    • {
    • monmeCounter = monmeCount;
    • }
    • cost -= monmeCounter*60;
    • int monmeCounter = Math.Min(cost / monmeValue, monmeCount);
    • cost -= monmeCounter * monmeValue;
    • if (monCount < cost)
    • {
    • return new[] { 0 };//leaving the market
    • }
    • return new[] { monCount, monmeCount, totalValue, monmeCounter + cost };
    • return (monCount < cost) ?
    • new[] { 0 } : //leaving the market
    • new[] { monCount, monmeCount, totalValue, monmeCounter + cost };
    • }
    • }
Code
Diff
  • #!/bin/bash
    
    if [ $# -eq 1 ]; then
      echo "$1"
    fi
    • echo "$1"
    • #!/bin/bash
    • if [ $# -eq 1 ]; then
    • echo "$1"
    • fi

Prints "Hello Bash" and any parameters to stdout.

Code
Diff
  • #!/bin/bash
    
    echo Hello Bash!
    
    if [ $# -eq 1 ]; then
      echo "Hello, $1!"
    else
      echo "No parameters found."
    fi
    • echo Hello Bash!
    • #!/bin/bash
    • echo Hello Bash!
    • if [ $# -eq 1 ]; then
    • echo "Hello, $1!"
    • else
    • echo "No parameters found."
    • fi