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

Shortified 😉

Code
Diff
  • interface Kata {
      static int doubleValue(int x) {
        return x + x;
      }
    }
    • package cat;
    • public class kata{
    • public static int doubleValue(int x) {
    • return x*2;
    • interface Kata {
    • static int doubleValue(int x) {
    • return x + x;
    • }
    • }
Code
Diff
  • //Given 2 Arrays, Return True if arrays contain common item, else false.
    //e.g a= ['a','b','g','c'] and b =['z','e','c'] returns true
    //input : 2 arrays
    //output: bool
    using System.Collections.Generic;
    using System.Linq;
    public class Kata{
      public static bool ContainsCommonItem(char[] a, char[] b){ //not mine
        for(int i=0;i<a.Length;i++)
          for(int j=0; j< b.Length; j++)
            if(a[i]==b[j])
              return true;
        return false;
      }
      public static bool ContainsCommonItemBetter(char[] a,char[]b){ //not min
        
        HashSet<char> items = new HashSet<char>();
        
        foreach(char item in a)
          items.Add(item);
        for (int i =0; i< b.Length; i++)
          if (items.Contains(b[i]))
            return true;
        return false;
      }
      public static bool ContainsCommonItemMoreSimple(char[] a, char[] b) // mine
      {
          var charsExcistingInBoth = a.Intersect(b);
          return charsExcistingInBoth.Count() > 0? true : false;
      }
      
      public static bool ContainsCommonItemUsingAny(char[] a, char[] b)
      {
          return a.Any(ch => b.Contains(ch));
      }
      
        
    }
    
    • //Given 2 Arrays, Return True if arrays contain common item, else false.
    • //e.g a= ['a','b','g','c'] and b =['z','e','c'] returns true
    • //input : 2 arrays
    • //output: bool
    • using System.Collections.Generic;
    • using System.Linq;
    • public class Kata{
    • public static bool ContainsCommonItem(char[] a, char[] b){ //not mine
    • for(int i=0;i<a.Length;i++)
    • for(int j=0; j< b.Length; j++)
    • if(a[i]==b[j])
    • return true;
    • return false;
    • }
    • public static bool ContainsCommonItemBetter(char[] a,char[]b){ //not min
    • HashSet<char> items = new HashSet<char>();
    • foreach(char item in a)
    • items.Add(item);
    • for (int i =0; i< b.Length; i++)
    • if (items.Contains(b[i]))
    • return true;
    • return false;
    • }
    • public static bool ContainsCommonItemMoreSimple(char[] a, char[] b) // mine
    • {
    • var charsExcistingInBoth = a.Intersect(b);
    • return charsExcistingInBoth.Count() > 0? true : false;
    • }
    • public static bool ContainsCommonItemUsingAny(char[] a, char[] b)
    • {
    • return a.Any(ch => b.Contains(ch));
    • }
    • }
Code
Diff
  • unsigned long long div2(unsigned long long a) {
      return a >>1;
    }
    • unsigned long long div2(unsigned long long a) {
    • return a?a/((a/a)+(a/a)):a;
    • return a >>1;
    • }

A little cup of javascript golf

  • Use of javascript interpolation string
  • Convert to number with +
  • Use of letter for variables
Code
Diff
  • const formatIfNumber = (v, n) => v / 2 
    ? + (Math.round(`${v}e${n}`) + `e-${n}` ) : v
    • const formatIfNumber = (value, numberOfPlaces) =>
    • value / 2
    • ? Number(Math.round(value + 'e' + numberOfPlaces) + 'e-' + numberOfPlaces)
    • : value
    • const formatIfNumber = (v, n) => v / 2
    • ? + (Math.round(`${v}e${n}`) + `e-${n}` ) : v
Code
Diff
  • helloWorld=n=>`Hello ${n}`
    • const helloWorld=n=>`Hello World ${n}`
    • helloWorld=n=>`Hello ${n}`
Code
Diff
  • module rec ExampleSolution
      let findUniqueNumber (array : _ array) =
        let guess = array.[0]
        findUniqueNumber' array guess 1
        
      let rec findUniqueNumber' (array : _ array) guess n =
        let a = array.[n]
        let b = array.[n+1]
        match guess = a, guess = b with
        | true, true -> findUniqueNumber' array guess (n+1)
        | false, true -> a
        | true, false -> b
        | false, false -> guess
    • module ExampleSolution
    • let findUniqueNumber array =
    • () // your code goes here
    • module rec ExampleSolution
    • let findUniqueNumber (array : _ array) =
    • let guess = array.[0]
    • findUniqueNumber' array guess 1
    • let rec findUniqueNumber' (array : _ array) guess n =
    • let a = array.[n]
    • let b = array.[n+1]
    • match guess = a, guess = b with
    • | true, true -> findUniqueNumber' array guess (n+1)
    • | false, true -> a
    • | true, false -> b
    • | false, false -> guess