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
  • 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
Code
Diff
  • const getMin = (l) => l.filter(i => i > 0).sort((a, b) => a - b)[0] || 0
    
    • function getMin(list) {
    • x = Math.min(...list.filter(i => i > 0));
    • return x !== Infinity ? x : 0
    • }
    • const getMin = (l) => l.filter(i => i > 0).sort((a, b) => a - b)[0] || 0

Сan not be stored list in the memory

Code
Diff
  • def fib(x):
        f1, f2 = 0, 1
        for x in range(x):
            f1, f2 = f2, (f1 + f2)
        return f2
    • def fib(x):
    • fib = [1,1]
    • for x in range(x-1):
    • fib.append(fib[-2]+fib[-1])
    • return fib[-1]
    • f1, f2 = 0, 1
    • for x in range(x):
    • f1, f2 = f2, (f1 + f2)
    • return f2
Code
Diff
  • var longestString = (str) => require('lodash')(str.split(' ')).maxBy('length');
    • var longestString = (str) => str.split(' ').sort((a, b) => b.length - a.length)[0];
    • var longestString = (str) => require('lodash')(str.split(' ')).maxBy('length');