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 mergeArrays(a, b, o=[]) {
      while (a.length && b.length)
        o.push((a[0] < b[0] ? a : b).shift())
      return o.concat(a).concat(b)
    }
    • function mergeArrays(arrA, arrB) {
    • const output = [];
    • const arrAClone = [...arrA];
    • const arrBClone = [...arrB];
    • let nextSmallestA = arrAClone.shift();
    • let nextSmallestB = arrBClone.shift();
    • while (nextSmallestA !== undefined || nextSmallestB !== undefined) {
    • if (nextSmallestA === undefined || nextSmallestB < nextSmallestA) {
    • output.push(nextSmallestB);
    • nextSmallestB = arrBClone.shift();
    • } else {
    • output.push(nextSmallestA);
    • nextSmallestA = arrAClone.shift();
    • }
    • }
    • return output;
    • }
    • function mergeArrays(a, b, o=[]) {
    • while (a.length && b.length)
    • o.push((a[0] < b[0] ? a : b).shift())
    • return o.concat(a).concat(b)
    • }
Code
Diff
  • class UniqueInOrderIterator:
        def __init__(self, iterable):
            self.__iterable = iterable
            self.__currentPosition = 0
            self.__lastElement = None
        
        def __iter__(self):
            return self
        
        def __next__(self):
            self.__pointToNextValidElement()
            result = self.__pointedElement()
            self.__pointToNextElement()
            return result
        
        def __pointToNextValidElement(self):
            while (self.__currentPosition < len(self.__iterable)
                    and self.__iterable[self.__currentPosition] == self.__lastElement):
                self.__pointToNextElement()
        
        def __pointedElement(self):
            return self.__iterable[self.__currentPosition]
        
        def __pointToNextElement(self):
            self.__lastElement = self.__pointedElement()
            self.__currentPosition += 1
            self.__stopIfEndReached()
        
        def __stopIfEndReached(self):
            if self.__currentPosition >= len(self.__iterable):
                raise StopIteration
        
                
    
    def unique_in_order(iterable):
        unique = []
        uniqueInOrderIterator = UniqueInOrderIterator(iterable)
        
        for element in uniqueInOrderIterator:
            unique.append(element)
    
        return unique
    • class UniqueInOrderIterator:
    • def __init__(self, iterable):
    • self.__iterable = iterable
    • self.__currentPosition = 0
    • self.__lastElement = None
    • def __iter__(self):
    • return self
    • def __next__(self):
    • self.__pointToNextValidElement()
    • result = self.__pointedElement()
    • self.__pointToNextElement()
    • return result
    • def __pointToNextValidElement(self):
    • while (self.__currentPosition < len(self.__iterable)
    • and self.__iterable[self.__currentPosition] == self.__lastElement):
    • self.__pointToNextElement()
    • def __pointedElement(self):
    • return self.__iterable[self.__currentPosition]
    • def __pointToNextElement(self):
    • self.__lastElement = self.__pointedElement()
    • self.__currentPosition += 1
    • self.__stopIfEndReached()
    • def __stopIfEndReached(self):
    • if self.__currentPosition >= len(self.__iterable):
    • raise StopIteration
    • def unique_in_order(iterable):
    • unique = []
    • uniqueInOrderIterator = UniqueInOrderIterator(iterable)
    • for i in range(len(iterable)):
    • if (i == 0):
    • unique.append(iterable[i])
    • elif iterable[i] != unique[-1]:
    • unique.append(iterable[i])
    • for element in uniqueInOrderIterator:
    • unique.append(element)
    • return unique

Here's some of my expirements

Code
Diff
  • public class Kumite{
      public static String switchout(String in, String replace, String instead){
        return in.replaceAll(replace, instead);}}
    • switchout = str.replace
    • public class Kumite{
    • public static String switchout(String in, String replace, String instead){
    • return in.replaceAll(replace, instead);}}
Fundamentals
Code
Diff
  • def interleave(*args):
        r = []
        for i in range(max(len(x) for x in args)):
            for x in args:
                if i < len(x):
                    r.append(x[i])
                else:
                    break
        return r
    • def interleave(*argv):
    • lists = len(argv)
    • if 1 == lists:
    • return argv[0]
    • else:
    • o = [x for t in zip(*argv) for x in t]
    • for i in reversed(range(0, lists - 1)):
    • l = len(argv[i + 1])
    • lists = []
    • for _list in argv[:i+1]:
    • lists.append(_list[l:])
    • o += [x for t in zip(*lists) for x in t]
    • return o
    • def interleave(*args):
    • r = []
    • for i in range(max(len(x) for x in args)):
    • for x in args:
    • if i < len(x):
    • r.append(x[i])
    • else:
    • break
    • return r
Code
Diff
  • const returnhundred = () => +(~(~[]<<!![])<<!![]<<!![]).toString(~(~[]<<!![])<<!![]);
    • const returnhundred = () => process.version.slice(1).split('.')[0] ** 2;
    • // WARNING: Only works in Node 10. Node 8 will give 80 and Node 6 will give 60
    • const returnhundred = () => +(~(~[]<<!![])<<!![]<<!![]).toString(~(~[]<<!![])<<!![]);
Arrays
Data Types
Control Flow
Basic Language Features
Fundamentals

and simplified more

Code
Diff
  • def palindrome(x) 
      x.chars.zip(x.chars.reverse).all? do |a, b| a == b end.to_s.upcase
    end
    • def palindrome(x)
    • x.chars.zip(x.chars.reverse).sum do |a, b| (a.ord - b.ord).abs end.zero?.to_s.upcase
    • x.chars.zip(x.chars.reverse).all? do |a, b| a == b end.to_s.upcase
    • end