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
  • 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');
Code
Diff
  • function getMin(list) {
      x = Math.min(...list.filter(i => i > 0));
      return x !== Infinity ? x : 0
    }
    • function getMin(list) {
    • let ret = list.reduce((prev, curr) => {
    • if (curr <= 0) return prev;
    • return (prev <= 0) ? curr : Math.min(curr, prev);
    • }, -1);
    • return ret > 0 ? ret : 0;
    • x = Math.min(...list.filter(i => i > 0));
    • return x !== Infinity ? x : 0
    • }
Code
Diff
  • from itertools import *
    
    def permut(arr):
        return [list(p) for p in permutations(arr)]
    • from itertools import *
    • def permut(arr):
    • resL = []
    • for perm in permutations(arr):
    • resL.append(list(perm))
    • return resL
    • return [list(p) for p in permutations(arr)]
Code
Diff
  • def counter(arr)
        arr.each_with_object(Hash.new(0)) { |n, counts| counts[n] += 1 }
    end
    
    def count_occur_each_element(arr)
        counter(arr).sort
    end
        
    • def counter(arr)
    • counts = Hash.new 0
    • arr.each do |n|
    • counts[n] += 1
    • end
    • return counts
    • arr.each_with_object(Hash.new(0)) { |n, counts| counts[n] += 1 }
    • end
    • def count_occur_each_element(arr)
    • if arr == []
    • return []
    • end
    • count_pairs = []
    • counts = counter(arr)
    • counts.each do |k, v|
    • count_pairs << [k, v]
    • end
    • count_pairs.sort!
    • return count_pairs
    • counter(arr).sort
    • end
Code
Diff
  • object Scala extends App {
      object StringUtilities {
        def upper(strings: String*) = strings.map(_.toUpperCase).mkString(" ")
      }
      
      println( StringUtilities.upper("A", "First", "Scala", "Program") )
    }
    • object Scala extends App {
    • object StringUtilities {
    • def upper(strings: String*): Seq[String] = {
    • strings.map(_.toUpperCase)
    • }
    • def upper(strings: String*) = strings.map(_.toUpperCase).mkString(" ")
    • }
    • println(StringUtilities.upper("A", "First", "Scala", "Program") mkString " ")
    • println( StringUtilities.upper("A", "First", "Scala", "Program") )
    • }
Code
Diff
  • var getAge = (today, dob) => (today && dob) ? (new Date(today)).getYear() - new Date(dob).getYear() : null;
    • var getAge = function(today, dob) {
    • if(!today || !dob) {
    • return null;
    • }
    • var now = new Date(today);
    • return now.getYear() - new Date(dob).getYear();
    • };
    • var getAge = (today, dob) => (today && dob) ? (new Date(today)).getYear() - new Date(dob).getYear() : null;
Code
Diff
  • var middleCharacter = (str) => str.slice(str.length/2 - !(str.length % 2), str.length/2+1);
    • function middleCharacter(str) {
    • return str.slice(str.length/2 - !(str.length % 2), str.length/2+1);
    • };
    • var middleCharacter = (str) => str.slice(str.length/2 - !(str.length % 2), str.length/2+1);
Fundamentals
Arrays
Data Types
Code
Diff
  • var thirdGreatest = (arr) => arr.sort((a,b) => a - b)[arr.length - 3];
    • function thirdGreatest(arr){
    • return arr.sort( (a,b) => a - b)[arr.length-3]
    • }
    • var thirdGreatest = (arr) => arr.sort((a,b) => a - b)[arr.length - 3];