Begin a new Kumite
Search
About
  • Filter by Language:
  • 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.

Prints "Hello Bash" and any parameters to stdout.

Code
Diff
  • #!/bin/bash
    
    echo Hello Bash!
    
    if [ $# -eq 1 ]; then
      echo "Hello, $1!"
    else
      echo "No parameters found."
    fi
  • 1+
    #!/bin/bash
    
    2+
    11
    echo Hello Bash!
    
    4+
    5+
    if [ $# -eq 1 ]; then
    
    6+
      echo "Hello, $1!"
    
    7+
    else
    
    8+
      echo "No parameters found."
    
    9+
    fi
    

Recent Moves:

Code
Diff
  • const getMin = (l) => l.filter(i => i > 0).sort((a, b) => a - b)[0] || 0
    
  • 1
    function getMin(list) {
    
    2
      x = Math.min(...list.filter(i => i > 0));
    
    3
      return x !== Infinity ? x : 0
    
    4
    }
    
    1+
    const getMin = (l) => l.filter(i => i > 0).sort((a, b) => a - b)[0] || 0
    

Recent Moves:

Сan not be stored list in the memory

Code
Diff
  • def fib(x):
        f1, f2 = 0, 1
        for x in range(x):
            f1, f2 = f2, (f1 + f2)
        return f2
  • 11
    def fib(x):
    
    2
        fib = [1,1]
    
    3
        for x in range(x-1):
    
    4
            fib.append(fib[-2]+fib[-1])
    
    5
        return fib[-1]
    
    2+
        f1, f2 = 0, 1
    
    3+
        for x in range(x):
    
    4+
            f1, f2 = f2, (f1 + f2)
    
    5+
        return f2
    
Code
Diff
  • var longestString = (str) => require('lodash')(str.split(' ')).maxBy('length');
  • 1
    var longestString = (str) => str.split(' ').sort((a, b) => b.length - a.length)[0];
    
    1+
    var longestString = (str) => require('lodash')(str.split(' ')).maxBy('length');
    
Algorithms
(ns quicksort.core)

(defn quick-sort [nums]
  (if (< (count nums) 2) nums
    (concat
      (quick-sort (filter #(< % (first nums)) nums))
      (filter #(= % (first nums)) nums)
      (quick-sort (filter #(> % (first nums)) nums)))))
Stacks
Arrays
Code
Diff
  • import java.util.*;
    
    public class MatchingBrackets {
    
      static final Map<Character, Character> brackets = new HashMap<Character, Character>() {{
        put(')','(');
        put('}','{');
        put(']','[');
      }};
      
      public static boolean isBalanced(final String braces) {
        final Stack<Character> stack = new Stack<>();
        for (final char brace : braces.toCharArray()) {  
          if (!stack.isEmpty() && stack.peek() == brackets.get(brace)) {
            stack.pop();
          } else {
            stack.push(brace);
          }
        }
        return stack.isEmpty();
      }
    }
  • 11
    import java.util.*;
    
    22
    33
    public class MatchingBrackets {
    
    44
    5
      public static boolean isBalanced(String braces) {
    
    6
            Stack<String> stack = new Stack<>();
    
    7
            Map<String, String> enclosing = new HashMap<>();
    
    8
            enclosing.put(")","(");
    
    9
            enclosing.put("}","{");
    
    10
            enclosing.put("]","[");
    
    11
            for (char brace : braces.toCharArray()) {
    
    12
                final String strBrace = Character.toString(brace);
    
    13
                if (!stack.isEmpty() && stack.peek().equals(enclosing.get(strBrace))) {
    
    14
                    stack.pop();
    
    15
                } else {
    
    16
                    stack.push(strBrace);
    
    17
                }
    
    18
            }
    
    19
            return stack.isEmpty();
    
    5+
      static final Map<Character, Character> brackets = new HashMap<Character, Character>() {{
    
    6+
        put(')','(');
    
    7+
        put('}','{');
    
    8+
        put(']','[');
    
    9+
      }};
    
    10+
      
    
    11+
      public static boolean isBalanced(final String braces) {
    
    12+
        final Stack<Character> stack = new Stack<>();
    
    13+
        for (final char brace : braces.toCharArray()) {  
    
    14+
          if (!stack.isEmpty() && stack.peek() == brackets.get(brace)) {
    
    15+
            stack.pop();
    
    16+
          } else {
    
    17+
            stack.push(brace);
    
    18+
          }
    
    2020
        }
    
    20+
        return stack.isEmpty();
    
    21+
      }
    
    2121
    }