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
Regular Expressions
Declarative Programming
Advanced Language Features
Programming Paradigms
Fundamentals
Strings

This regular expression is a little lack luster. I think it could be improved to account for hyphens and apostraphes that are supposed to be apart of a word. The objective here is to not accidentally capture punctuation mistakes.

Code
Diff
  • wordCount=s=>s.trim().match(/[A-Za-z0-9]+/mg).length;
    • wordCount=s=>s.trim().split(' ').length
    • wordCount=s=>s.trim().match(/[A-Za-z0-9]+/mg).length;
Algorithms
Logic
Code
Diff
  • const getDividors = n => {
      
      let result = [];
    
      for (let i = 1; i <= Math.floor(Math.sqrt(n)); i += 1)
        if (n % i === 0) { result.push(i); if (n / i !== i) result.push(n / i) }
        
      return result; // output array won't be sorted
      
    }
    • const getDividors = (n, result = []) => {
    • const getDividors = n => {
    • let result = [];
    • for (let i = 1; i <= Math.floor(Math.sqrt(n)); i++)
    • for (let i = 1; i <= Math.floor(Math.sqrt(n)); i += 1)
    • if (n % i === 0) { result.push(i); if (n / i !== i) result.push(n / i) }
    • return result; // output array won't be sorted
    • }
Algorithms
Logic
Code
Diff
  • const flatten = arr =>
      arr.reduce((acc, item) =>  acc.concat(Array.isArray(item) ? flatten(item) : item), []);
    • const flatten = arr =>
    • arr.reduce((acc, item) => acc.concat(Array.isArray(item) ? flatten(item) : [item]), []);
    • arr.reduce((acc, item) => acc.concat(Array.isArray(item) ? flatten(item) : item), []);
Search
Algorithms
Logic

Now it's even more prettier

Code
Diff
  • import java.util.*;
    
    class Node {
      int value;
      Node left;
      Node right;
      
      public Node(int value) {
        this.value = value;
      }
    }
    
    
    class BST {
      public static boolean search(Node root, int key) {   
          if (root == null)
            return false;
          if (root.value == key)
            return true;
          
          return root.value > key ? search(root.left, key) : search(root.right, key); 
      }
    }
    • import java.util.*;
    • class Node {
    • int value;
    • Node left;
    • Node right;
    • public Node(int value) {
    • this.value = value;
    • }
    • }
    • class BST {
    • public static boolean search(Node root, int key) {
    • if (root == null){
    • return false;
    • }else if(root.value == key) {
    • if (root == null)
    • return false;
    • if (root.value == key)
    • return true;
    • } else{
    • return root.value > key ? search(root.left, key) : search(root.right, key);
    • }
    • return root.value > key ? search(root.left, key) : search(root.right, key);
    • }
    • }
Code
Diff
  • import java.util.*;
    public class Average {
       public static int averageFinder(int[] arr) {
         return Arrays.stream(arr).sum() / arr.length;
       };
    }
    • import java.util.*;
    • public class Average {
    • public static int averageFinder(int[] arr) {
    • int total = 0;
    • for(int num: arr){
    • total += num;
    • }
    • return total / arr.length;
    • }
    • return Arrays.stream(arr).sum() / arr.length;
    • };
    • }