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
  • returnHundred=()=>100;
    • function returnhundred(){return 'd'.charCodeAt();}
    • returnHundred=()=>100;
Code
Diff
  • def find_only(values):
        return sorted(set(values), key=lambda x: values.count(x))[0]
    • from collections import Counter
    • def FindOnly(values):
    • return Counter(values).most_common()[::-1][0][0]
    • def find_only(values):
    • return sorted(set(values), key=lambda x: values.count(x))[0]
Code
Diff
  • using System;
    using System.Collections.Generic;
    using System.Linq;
    namespace Solution
    {
        public class ObjectShuffler
        {
           private Random rnd = new Random();
            public T Shuffle<T>(Dictionary<T, int> parameterDict)
            {
                //Remove wrong configuration.
                parameterDict = (from i in parameterDict
                                 where i.Value > 0
                                 select i).ToDictionary(x => x.Key, x => x.Value);
                //Error Handling
                if (parameterDict.Count == 0)
                {
                    throw new Exception("Can't shuffle an empty list."); 
                }
                //Do Work
                var sumItemsValue = (from x in parameterDict select x.Value).Sum();
                var randNr = this.rnd.Next(1, sumItemsValue + 1);
                var stepSum = 0;
                foreach (var item in parameterDict)
                {
                    stepSum = stepSum + item.Value;
                    if (randNr <= stepSum)
                    {
                        return item.Key;
                    }
                }
                // This can't happen.
                throw new Exception("Run to far.");
            }
        }
    }
    
    • using System;
    • using System.Collections.Generic;
    • using System.Linq;
    • namespace Solution
    • {
    • public class ObjectShuffler
    • {
    • private Random rnd = new Random();
    • public T Shuffle<T>(Dictionary<T, int> parameterDict)
    • {
    • //Remove wrong configuration.
    • parameterDict = (from i in parameterDict
    • where i.Value > 0
    • select i).ToDictionary(x => x.Key, x => x.Value);
    • //Error Handling
    • if (parameterDict.Count == 0)
    • {
    • throw new Exception("Can't shuffle an empty list.");
    • }
    • //Do Work
    • var sumItemsValue = (from x in parameterDict select x.Value).Sum();
    • var randNr = this.rnd.Next(1, sumItemsValue + 1);
    • var stepSum = 0;
    • foreach (var item in parameterDict)
    • {
    • stepSum = stepSum + item.Value;
    • if (randNr <= stepSum)
    • {
    • return item.Key;
    • }
    • }
    • // This can't happen.
    • throw new Exception("Run to far.");
    • }
    • }
    • }
Code
Diff
  • //We have Matrix Matrix::GetCofactorMatrix() to return cofactor matrix
    //double & Matrix::GetElement(int _Row, int _Col) to return _Row and _Col of double element of matrix
    double Matrix::GetValueOfDeterminant()
    {
        if((2 == MaxRow) && (2 == MaxCol)){
            return GetElement(1,1) * GetElement(2,2) - GetElement(1,2) * GetElement(2,1);}
        else{
            double ResultValue = 0;
            for(int c = 1; c <= MaxCol; c++){
                int PowOfNegativeOne = std::pow(-1, c);
                ResultValue += GetCofactorMatrix(1,c).GetValueOfDeterminant() * GetElement(1,c) * PowOfNegativeOne;}
            return ResultValue;  }
        }
    • //We have Matrix Matrix::GetCofactorMatrix() to return cofactor matrix
    • //double & Matrix::GetElement(int _Row, int _Col) to return _Row and _Col of double element of matrix
    • double Matrix::GetValueOfDeterminant()
    • {
    • if((2 == MaxRow) && (2 == MaxCol))
    • {
    • return GetElement(1,1) * GetElement(2,2) - GetElement(1,2) * GetElement(2,1);
    • }
    • else
    • {
    • if((2 == MaxRow) && (2 == MaxCol)){
    • return GetElement(1,1) * GetElement(2,2) - GetElement(1,2) * GetElement(2,1);}
    • else{
    • double ResultValue = 0;
    • for(int c = 1; c <= MaxCol; c++)
    • {
    • for(int c = 1; c <= MaxCol; c++){
    • int PowOfNegativeOne = std::pow(-1, c);
    • ResultValue += GetCofactorMatrix(1,c).GetValueOfDeterminant() * GetElement(1,c) * PowOfNegativeOne;
    • }
    • return ResultValue;
    • }
    • }
    • ResultValue += GetCofactorMatrix(1,c).GetValueOfDeterminant() * GetElement(1,c) * PowOfNegativeOne;}
    • return ResultValue; }
    • }
Code
Diff
  • function fizzBuzz(n){for (let i=1;i<=n;i++)console.log((i%3 ?'':'fizz')+(i%5 ?'':'buzz')||i)}
    • function fizzBuzz(n) {
    • for (let i = 1; i <= n; i++)
    • console.log((i % 3 ? '' : 'fizz') + (i % 5 ? '' : 'buzz') || i)
    • }
    • function fizzBuzz(n){for (let i=1;i<=n;i++)console.log((i%3 ?'':'fizz')+(i%5 ?'':'buzz')||i)}
Code
Diff
  • public class ThirdAngle{public static int otherAngle(int angle1,int angle2){return 180-angle1-angle2;}}
    • public class ThirdAngle {
    • public static int otherAngle(int angle1, int angle2) {
    • return 180-angle1-angle2;
    • }
    • }
    • public class ThirdAngle{public static int otherAngle(int angle1,int angle2){return 180-angle1-angle2;}}
Code
Diff
  • from math import sqrt
    
    def primemaker(x):
        primes = []
        if x < 2:
            return []
        else:  
            primes.append(2)
            for possible_prime in range(3,(x+1), 2): #only odd numbers
                limit = sqrt(possible_prime)
                for prime in primes:
                    if prime > limit:
                        primes.append(possible_prime)
                        break
                    if not possible_prime % prime:
                        break
        return primes
    
    
    • from math import sqrt
    • def primemaker(x):
    • primes = []
    • if x < 2:
    • return []
    • else:
    • primes.append(2)
    • for possible_prime in range(3,(x+1), 2): #only odd numbers
    • limit = sqrt(possible_prime)
    • for prime in primes:
    • if prime > limit:
    • primes.append(possible_prime)
    • break
    • if 0 == possible_prime % prime:
    • if not possible_prime % prime:
    • break
    • return primes