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
  • use std::iter::Sum;
    
    fn sum<T: Copy + Sum>(arr: &[T]) -> T {
        arr.iter().copied().sum()
    }
    
    • module Sum (Sum.sum) where
    • use std::iter::Sum;
    • import Prelude hiding (sum)
    • sum :: [Word] -> Word
    • sum = foldr1 (+)
    • fn sum<T: Copy + Sum>(arr: &[T]) -> T {
    • arr.iter().copied().sum()
    • }
Code
Diff
  • fn fibonacci(n: usize) -> u128 {
        let (mut n1, mut n2) = (1, 1);
        for _ in 2..n {
            (n1, n2) = (n2, n1 + n2);
        }
        n2
    }
    • import java.util.HashMap;
    • import java.util.Map;
    • public class Fibonacci {
    • private static Map<Integer, Long> memoizationMap = new HashMap<>();
    • public static long calcFibo(int n) {
    • if (n <= 1) {
    • return n;
    • }
    • if (memoizationMap.containsKey(n)) {
    • return memoizationMap.get(n);
    • }
    • long fiboValue = calcFibo(n - 1) + calcFibo(n - 2);
    • memoizationMap.put(n, fiboValue);
    • return fiboValue;
    • }
    • fn fibonacci(n: usize) -> u128 {
    • let (mut n1, mut n2) = (1, 1);
    • for _ in 2..n {
    • (n1, n2) = (n2, n1 + n2);
    • }
    • n2
    • }
Fundamentals
Strings
Code
Diff
  • from collections import deque
    
    def reverse_string(string):
        return string[::-1]
    • from collections import deque
    • def reverse_string(string):
    • reversed_str = deque("")
    • [reversed_str.appendleft(letter) for letter in string]
    • return "".join(reversed_str)
    • return string[::-1]
Code
Diff
  • fn add(a: i32, b: i32) -> i32 {
        a + b
    }
    • namespace Solution
    • {
    • public class MyCalculator
    • {
    • public int Add(int a, int b)
    • {
    • return a + b;
    • }
    • }
    • fn add(a: i32, b: i32) -> i32 {
    • a + b
    • }

A function that returns the multiplication of the input arguments. Any number of input arguments can be used.

Code
Diff
  • function multiply(...nums){
      return nums.reduce((acc, num) => acc * num, 1)
    }
    
    • # def multiply (a,b):
    • # return a * b
    • multiply = lambda a, b: a * b
    • function multiply(...nums){
    • return nums.reduce((acc, num) => acc * num, 1)
    • }
Code
Diff
  • fn greeting(name: &str, formal_rank: Option<&str>) -> String {
        if let Some(title) = formal_rank {
            format!("Hello, {title} {name}.")    
        } else {
            format!("Hey {name}!")
        }
    }
    • class greeting:
    • def __init__(self, name: str, formal: bool = False):
    • self.name = name
    • self.formal = formal
    • def __call__(self) -> str:
    • if self.formal: return f'Hello, Sir {self.name}.'
    • else: return f'Hello, {self.name}!'
    • g1 = greeting('John')
    • g2 = greeting('Churchill', True)
    • print(g1()) # 'Hello, John!'
    • print(g2()) # 'Hello, Sir Churchill.'
    • fn greeting(name: &str, formal_rank: Option<&str>) -> String {
    • if let Some(title) = formal_rank {
    • format!("Hello, {title} {name}.")
    • } else {
    • format!("Hey {name}!")
    • }
    • }
Code
Diff
  • def test() :
        word = "test"
        return f"{word}"
    • def test() :
    • return "test"
    • word = "test"
    • return f"{word}"