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 middleCharacter(str) {
      return str.slice(str.length/2 - !(str.length % 2), str.length/2+1);
    };
    • function middleCharacter(str) {
    • if (str.length % 2 !== 0) {
    • return str.slice(str.length/2, str.length/2+1);
    • };
    • return str.slice(str.length/2-1, str.length/2+1);
    • return str.slice(str.length/2 - !(str.length % 2), str.length/2+1);
    • };
Code
Diff
  • function numSum(num){
      return (num * (num + 1)) / 2;
    }
    • function numSum(num){
    • var sum = 0;
    • for (var i = 1; i <= num; i++) {
    • sum += i
    • }
    • return sum
    • return (num * (num + 1)) / 2;
    • }
Mathematics
Algorithms
Logic
Numbers
Games
Fundamentals
Basic Language Features
Code
Diff
  • const whoShouldServe = (scoreLeft, scoreRight, servesCount) => {
      return Math.floor((scoreLeft + scoreRight) / servesCount) % 2 === 0 ? 'first' : 'second';
    };
    • function whoShouldServe($scoreLeft, $scoreRight, $servesCount) {
    • return floor(($scoreLeft + $scoreRight) / $servesCount) % 2 === 0 ? 'first' : 'second';
    • const whoShouldServe = (scoreLeft, scoreRight, servesCount) => {
    • return Math.floor((scoreLeft + scoreRight) / servesCount) % 2 === 0 ? 'first' : 'second';
    • };
Bash
Code
Diff
  • add_PATH() {
        echo -n "$PATH:$1" | awk 'BEGIN{RS=":";ORS=""}!x[$0]++{if(SEP){print ":"}print $0;SEP=1}'
    }
    
    echo "Original Path: $PATH"
    export PATH=$(add_PATH /usr/local/bin2)
    echo "New Path:      $PATH"
    
    • add_PATH() {
    • t=$(echo $PATH | tr : '\n' | awk '!x[$0]++' | tr '\n' : | sed 's/.$//')
    • echo -n "$t"
    • unset t
    • echo -n "$PATH:$1" | awk 'BEGIN{RS=":";ORS=""}!x[$0]++{if(SEP){print ":"}print $0;SEP=1}'
    • }
    • echo "Original Path: $PATH"
    • export PATH=$(add_PATH /usr/local/bin)
    • echo "New Path: $PATH"
    • export PATH=$(add_PATH /usr/local/bin2)
    • echo "New Path: $PATH"
Functions
Control Flow
Basic Language Features
Fundamentals

This solution uses a simple hash for holding stringified args to quickly lookup the cache.

The assumption is that only one type of function signature is ever used.

Fundamentals
Code
Diff
  • using System.Numerics;
    
    public class basic 
    {
    		public static BigInteger pow(long down, ulong up)
    		{
    			BigInteger output = 1;
    			BigInteger cumulativeDown = down;
    
    			for(ulong bitChecker = 1; bitChecker > 0 && bitChecker <= up; bitChecker <<= 1)
    			{
    				if((bitChecker & up) != 0)
    				{
    					output *= cumulativeDown;
    				}
    
    				cumulativeDown *= cumulativeDown;
    			}
    
    			return output;
    		}
    }
    • using System.Numerics;
    • public class basic
    • {
    • public static BigInteger pow(long down, long up)
    • => up == 0 ? 1 : down * pow(down, up - 1);
    • public static BigInteger pow(long down, ulong up)
    • {
    • BigInteger output = 1;
    • BigInteger cumulativeDown = down;
    • for(ulong bitChecker = 1; bitChecker > 0 && bitChecker <= up; bitChecker <<= 1)
    • {
    • if((bitChecker & up) != 0)
    • {
    • output *= cumulativeDown;
    • }
    • cumulativeDown *= cumulativeDown;
    • }
    • return output;
    • }
    • }
Code
Diff
  • let spaceMaker=str=>[...str].join(' ');
    • function spaceMaker(str) {
    • return str.split("").join(" ");
    • }
    • let spaceMaker=str=>[...str].join(' ');