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
  • def sayHello(say):
        say.append("bulbul")
        return say
    • def sayHello(say):
    • l = ["bulbul", "8===D"]
    • return l
    • say.append("bulbul")
    • return say
Code
Diff
  • function greetLanguage(a = "Hello", b = "Javascript") { return `${a}, ${b}!`; }
    • function greetLanguage(a = "Hello", b = "Javascript") { return a + ", " + b + "!"; }
    • function greetLanguage(a = "Hello", b = "Javascript") { return `${a}, ${b}!`; }
Code
Diff
  • using System;
    using System.Linq;
    
    public class Kata
    {
          public static int DuplicateCount(string str)
          {
                return str
                    .ToLower()
                    .GroupBy(c => c)
                    .Aggregate(0, (current, next) => current + (next.Count() > 1 ? 1 : 0));
          }
    
    }
    • using System;
    • using System.Linq;
    • public class Kata
    • {
    • public static int DuplicateCount(string str)
    • {
    • var orderedLowercase = str.ToLower().OrderBy(c => c);
    • var countDuplicates = 0;
    • var countOccurrenciesCurrentCharacter = 1;
    • char? previousElement = null;
    • var firstElement = true;
    • foreach(var currentElement in orderedLowercase)
    • {
    • if (firstElement)
    • {
    • firstElement = false;
    • }
    • else
    • {
    • if (currentElement == previousElement.Value)
    • {
    • countOccurrenciesCurrentCharacter ++;
    • if (countOccurrenciesCurrentCharacter == 2)
    • {
    • countDuplicates ++;
    • }
    • }
    • else
    • {
    • countOccurrenciesCurrentCharacter = 1;
    • }
    • }
    • previousElement = currentElement;
    • }
    • return countDuplicates;
    • return str
    • .ToLower()
    • .GroupBy(c => c)
    • .Aggregate(0, (current, next) => current + (next.Count() > 1 ? 1 : 0));
    • }
    • }
Fundamentals
Code
Diff
  • #include<stdio.h>
    
    int hello(char* name) {
      printf("Hello, %s!\n", name);
      return 0;
    }
    • #include<stdio.h>
    • int main(int argc, char **argv) {
    • printf("Hello, %s!
    • ", argv[0]);
    • int hello(char* name) {
    • printf("Hello, %s!
    • ", name);
    • return 0;
    • }
Fundamentals
Arrays
Data Types
Code
Diff
  • const thirdGreatest = a => [...a].sort((a,b) => b - a)[2];
    • var thirdGreatest = a => JSON.parse(JSON.stringify(a)).sort((a,b) => b - a)[2];
    • const thirdGreatest = a => [...a].sort((a,b) => b - a)[2];
Code
Diff
  • function countCirculars(n) {
      let count = 0;
    
      for (let i=3;i<=n; i+=2) {
        if (isPrime(i) && isCirclePrime(i))
          count++;
      }
    
      return count+1;
    }
    
    function isPrime(n) {
      if (n <= 1)
        return false
      else if (n <= 3)
        return true
      else if ((n % 2) === 0 || n % 3 === 0)
        return false
    
      let i = 5;
    
      while (i*i <= n) {
        if (n % i === 0 || n % (i + 2) === 0)
          return false
        i = i + 6
      }
      return true
    }
    
    function isCirclePrime(n) {
      let strN = n.toString();
      for (let i = 1; i<strN.length; i++) {
        strN = shiftString(strN);
        if (!isPrime(parseInt(strN)))
          return false
      }
      return true;
    }
    
    function shiftString(str) {
      return str.substring(1) + str.substring(0,1);
    }
    
    • function countCirculars(n) {
    • let count = 0;
    • for (let i=3;i<=n; i+=2) {
    • if (isPrime(i) && isCirclePrime(i))
    • count++;
    • }
    • return count+1;
    • }
    • function isPrime(n) {
    • for (let i=2; i<=Math.sqrt(n); i++) {
    • if (n%i === 0)
    • return false;
    • if (n <= 1)
    • return false
    • else if (n <= 3)
    • return true
    • else if ((n % 2) === 0 || n % 3 === 0)
    • return false
    • let i = 5;
    • while (i*i <= n) {
    • if (n % i === 0 || n % (i + 2) === 0)
    • return false
    • i = i + 6
    • }
    • return true;
    • return true
    • }
    • function isCirclePrime(n) {
    • let strN = n.toString();
    • for (let i = 1; i<strN.length; i++) {
    • strN = shiftString(strN);
    • if (!isPrime(parseInt(strN)))
    • return false
    • }
    • return true;
    • }
    • function shiftString(str) {
    • return str.substring(1) + str.substring(0,1);
    • }
Code
Diff
  • package com.mystuff.juststuff;
    
    import java.text.*;
    import java.util.Calendar;
    import java.util.Date;
    import java.util.GregorianCalendar;
    import java.util.TreeSet;
    
    public class Palindrome {
    	SimpleDateFormat sdf;
    	
    	public Palindrome() {
    		this.sdf = new SimpleDateFormat("MMddyyyy");
    		sdf.setLenient(false);
    	}
    
    	public TreeSet<Date> countDatePalindromes(Date startDate, Date endDate) {
    		TreeSet<Date> palSet = new TreeSet<Date>();
    		GregorianCalendar startCal = new GregorianCalendar();
    		GregorianCalendar endCal = new GregorianCalendar();
    
    
        /*
          end date is chronologically before start date. flip them.
          NOTE: lines 23-30 should be a pre-condition to the countDatePalindromes method,
          so they should be deleted.
        */
    		if (startDate.getTime() > endDate.getTime()) {
    			startCal.setTime(endDate);
    			endCal.setTime(startDate);
    		}else {
    			startCal.setTime(startDate);
    			endCal.setTime(endDate);
    		}
    
    		String regularDate = null;
    		String palDate = null;
    		while ( (startCal.before(endCal)) || (startCal.equals(endCal)) ) {
    			regularDate = sdf.format(startCal.getTime());
    			palDate = palindromify(startCal.getTime());			
          
          // a date palindrome was found
    			if (regularDate.equals(palDate))
    				palSet.add(startCal.getTime());
            
    			startCal.add(Calendar.DAY_OF_MONTH, 1);
    		}	
    		return palSet;
    	}
    	
    	private String palindromify(final Date arg) {
    		StringBuffer palBuff = new StringBuffer(8);
        palBuff = sdf.format(arg, palBuff, new FieldPosition(0));
    		return palBuff.reverse().toString();
    	}
    
    }
    
    • package com.mystuff.juststuff;
    • import java.text.SimpleDateFormat;
    • import java.text.*;
    • import java.util.Calendar;
    • import java.util.Date;
    • import java.util.GregorianCalendar;
    • import java.util.TreeSet;
    • public class Palindrome
    • {
    • public class Palindrome {
    • SimpleDateFormat sdf;
    • public Palindrome()
    • {
    • public Palindrome() {
    • this.sdf = new SimpleDateFormat("MMddyyyy");
    • sdf.setLenient(false);
    • }
    • public TreeSet<Date> countDatePalindromes(Date startDate, Date endDate)
    • {
    • public TreeSet<Date> countDatePalindromes(Date startDate, Date endDate) {
    • TreeSet<Date> palSet = new TreeSet<Date>();
    • GregorianCalendar startCal = new GregorianCalendar();
    • GregorianCalendar endCal = new GregorianCalendar();
    • if (startDate.getTime() > endDate.getTime())
    • {
    • // end date is chronologically before start date. flip them.
    • // System.out.println("end is before start. must flip. start: " + sdf.format(startDate.getTime()) + " end: " + sdf.format(endDate.getTime()));
    • /*
    • end date is chronologically before start date. flip them.
    • NOTE: lines 23-30 should be a pre-condition to the countDatePalindromes method,
    • so they should be deleted.
    • */
    • if (startDate.getTime() > endDate.getTime()) {
    • startCal.setTime(endDate);
    • endCal.setTime(startDate);
    • }
    • else
    • {
    • // start date is chronologically prior to end date. just set the calendars as such.
    • }else {
    • startCal.setTime(startDate);
    • endCal.setTime(endDate);
    • }
    • // System.out.println("start should be before end. start: " + sdf.format(startCal.getTime()) + " end: " + sdf.format(endCal.getTime()));
    • String regularDate = null;
    • String palDate = null;
    • while ( (startCal.before(endCal)) || (startCal.equals(endCal)) )
    • {
    • while ( (startCal.before(endCal)) || (startCal.equals(endCal)) ) {
    • regularDate = sdf.format(startCal.getTime());
    • palDate = palindromify(startCal.getTime());
    • palDate = palindromify(startCal.getTime());
    • // a date palindrome was found
    • if (regularDate.equals(palDate))
    • {
    • // a date palindrome was found
    • // System.out.println("Found one! regular: " + regularDate + " palindrome: " + palDate);
    • palSet.add(startCal.getTime());
    • }
    • startCal.add(Calendar.DAY_OF_MONTH, 1);
    • }
    • // System.out.println("I found " + palSet.size() + " palindromes");
    • }
    • return palSet;
    • }
    • private String palindromify(final Date arg)
    • {
    • SimpleDateFormat sdf = new SimpleDateFormat("MMddyyyy");
    • sdf.setLenient(false);
    • private String palindromify(final Date arg) {
    • StringBuffer palBuff = new StringBuffer(8);
    • String pal = sdf.format(arg);
    • for (int i = pal.length(); i >= 1; i--)
    • {
    • palBuff.append(pal.charAt(i - 1));
    • }
    • return palBuff.toString();
    • palBuff = sdf.format(arg, palBuff, new FieldPosition(0));
    • return palBuff.reverse().toString();
    • }
    • }

This uses lambda expressions insted of return.

Code
Diff
  • using System.Linq;   
    public class Kata { public static string[] LiningUpHisStudents(string s) => s.Split(' ').OrderByDescending(x => x.Length).ThenByDescending(x => x).ToArray(); }
    • using System;
    • using System.Linq;
    • public class Kata
    • {
    • public static string[] LiningUpHisStudents(string s)
    • {
    • var query = s.Split(' ').OrderByDescending(x => x.Length).ThenByDescending(x => x).ToArray();
    • return query;
    • }
    • }
    • public class Kata { public static string[] LiningUpHisStudents(string s) => s.Split(' ').OrderByDescending(x => x.Length).ThenByDescending(x => x).ToArray(); }