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 wordCount(str) {
    // error on no matches.
    // also, are there any other characters besides \w and - that shouldn't break words?
      return str.match(/[\w-]+/g).length;
    }
    
    • function wordCount(str) {
    • return str.split(/\s/g).filter(x => x.length > 0).length;
    • // error on no matches.
    • // also, are there any other characters besides \w and - that shouldn't break words?
    • return str.match(/[\w-]+/g).length;
    • }

Lazy refactoring, reduced 8 if statements.

Code
Diff
  • function nextGeneration(grid) {
      return grid.map((row, rowIndex) => {
        return row.map((cell, colIndex) => {
          if (rowIndex !== 0 && colIndex !== 0 && rowIndex < grid.length - 1 && colIndex < row.length - 1) {
            let neighboursCount = (grid[rowIndex][colIndex + 1] === 1) + (grid[rowIndex][colIndex - 1] === 1) + (grid[rowIndex + 1][colIndex] === 1) + (grid[rowIndex - 1][colIndex] === 1) + (grid[rowIndex + 1][colIndex + 1] === 1) + (grid[rowIndex + 1][colIndex - 1] === 1) + (grid[rowIndex - 1][colIndex + 1] === 1) + (grid[rowIndex - 1][colIndex - 1] === 1);
            if (cell === 1) {
              if (neighboursCount === 2 || neighboursCount === 3 ) {
                return 1;
              }
            } else {
              if (neighboursCount === 3 ) {
                return 1;
              }
            }
            return 0;
          }
          return 0;
        });
      });
    }
    • function nextGeneration(grid) {
    • return grid.map((row, rowIndex) => {
    • return row.map((cell, colIndex) => {
    • if (rowIndex !== 0 && colIndex !== 0 && rowIndex < grid.length - 1 && colIndex < row.length - 1) {
    • let neighboursCount = 0;
    • if (grid[rowIndex][colIndex + 1] === 1) neighboursCount++;
    • if (grid[rowIndex][colIndex - 1] === 1) neighboursCount++;
    • if (grid[rowIndex + 1][colIndex] === 1) neighboursCount++;
    • if (grid[rowIndex - 1][colIndex] === 1) neighboursCount++;
    • if (grid[rowIndex + 1][colIndex + 1] === 1) neighboursCount++;
    • if (grid[rowIndex + 1][colIndex - 1] === 1) neighboursCount++;
    • if (grid[rowIndex - 1][colIndex + 1] === 1) neighboursCount++;
    • if (grid[rowIndex - 1][colIndex - 1] === 1) neighboursCount++;
    • let neighboursCount = (grid[rowIndex][colIndex + 1] === 1) + (grid[rowIndex][colIndex - 1] === 1) + (grid[rowIndex + 1][colIndex] === 1) + (grid[rowIndex - 1][colIndex] === 1) + (grid[rowIndex + 1][colIndex + 1] === 1) + (grid[rowIndex + 1][colIndex - 1] === 1) + (grid[rowIndex - 1][colIndex + 1] === 1) + (grid[rowIndex - 1][colIndex - 1] === 1);
    • if (cell === 1) {
    • if (neighboursCount === 2 || neighboursCount === 3 ) {
    • return 1;
    • }
    • } else {
    • if (neighboursCount === 3 ) {
    • return 1;
    • }
    • }
    • return 0;
    • }
    • return 0;
    • });
    • });
    • }
Code
Diff
  • #include <functional>
    
    bool Or(bool a, bool b){
    	return std::logical_or<>()(a, b);
    }
    
    bool Xor(bool a, bool b){
    	return std::not_equal_to<>()(a, b);
    }
    
    bool And(bool a, bool b){
    	return std::logical_and<>()(a, b);
    }
    
    • #include <functional>
    • bool Or(bool a, bool b){
    • if(!a){
    • if(!b){
    • return false;
    • }
    • }
    • return true;
    • return std::logical_or<>()(a, b);
    • }
    • bool Xor(bool a, bool b){
    • return a != b;
    • return std::not_equal_to<>()(a, b);
    • }
    • bool And(bool a, bool b){
    • if(a){
    • if(b){
    • return true;
    • }
    • }
    • return false;
    • return std::logical_and<>()(a, b);
    • }
Code
Diff
  • def mul():
        return sum([i for i in range(1000) if i%3 == 0 or i%5 == 0])
        
    • def mul():
    • sum=0
    • for i in range(1, 1000):
    • if(i % 3 == 0 or i % 5 == 0):
    • sum += i
    • return sum
    • return sum([i for i in range(1000) if i%3 == 0 or i%5 == 0])
Numbers
Data Types
Integers
Algorithms
Logic
Code
Diff
  • using System;
    using System.Linq;
    
    public class Kumite
    {
      public static int Digits(ulong n)
      {
        //GEEEEEEET DUUUUUUNKED OOOOOOOOOOOOOON
        int theseDigitsShouldREALLYBeCountedImSureOfIt = n
        .ToString()
        .ToCharArray()
        .Select((c,i)=>new{_char = c, ShouldBeCounted = true, index = i})
        .Select((a,i)=>new{charValue = a._char-'0', shouldREALLYbecounted = a.ShouldBeCounted && a.index==i})
        .OrderBy(a=>a.charValue)
        .ToArray()
        .Where(a=>a.shouldREALLYbecounted.ToString()=="True")
        .ToList()
        .ToArray()
        .Length;
        
        
        int thatNameWasTooLong = theseDigitsShouldREALLYBeCountedImSureOfIt;
        int soWasThatOne = thatNameWasTooLong;
        int betterstill = soWasThatOne;
        int thisone = betterstill;
        int _this = thisone;
        int _ = _this;
        return _;
       } 
    }
    • using System;
    • using System.Linq;
    • public class Kumite
    • {
    • // Unrolled div loop
    • public static int Digits(ulong n) => n.ToString().Length;
    • public static int Digits(ulong n)
    • {
    • //GEEEEEEET DUUUUUUNKED OOOOOOOOOOOOOON
    • int theseDigitsShouldREALLYBeCountedImSureOfIt = n
    • .ToString()
    • .ToCharArray()
    • .Select((c,i)=>new{_char = c, ShouldBeCounted = true, index = i})
    • .Select((a,i)=>new{charValue = a._char-'0', shouldREALLYbecounted = a.ShouldBeCounted && a.index==i})
    • .OrderBy(a=>a.charValue)
    • .ToArray()
    • .Where(a=>a.shouldREALLYbecounted.ToString()=="True")
    • .ToList()
    • .ToArray()
    • .Length;
    • int thatNameWasTooLong = theseDigitsShouldREALLYBeCountedImSureOfIt;
    • int soWasThatOne = thatNameWasTooLong;
    • int betterstill = soWasThatOne;
    • int thisone = betterstill;
    • int _this = thisone;
    • int _ = _this;
    • return _;
    • }
    • }
Code
Diff
  • // add the values "codewars" to the websites array
    var websites = ['codewars'];
    • // add the values "codewars" to the websites array
    • var websites = ['codears'];
    • var websites = ['codewars'];
Code
Diff
  • #define add std::plus<>()
    • template<typename T>
    • T add(const T& a, const T &b){
    • return std::plus<T>()(a, b);
    • }
    • #define add std::plus<>()