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
  • module Sum (Sum.sum) where
    
    import Prelude hiding (sum)
    
    sum :: [Word] -> Word
    sum xs | null xs = 0 | otherwise = foldr1 (+) xs
    • module Sum (Sum.sum) where
    • import Prelude hiding (sum)
    • sum :: [Word] -> Word
    • sum xs = if xs == [] then 0 else foldr1 (+) xs
    • sum xs | null xs = 0 | otherwise = foldr1 (+) xs
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}"
Code
Diff
  • def est_height(g,d,m):
        return(d+m+1)/2if g=="boy"else(d+m-1)/2
    • def est_height(gender,dad_height,mom_height):
    • return (dad_height+mom_height+1)/2 if gender == "boy" else (dad_height+mom_height-1)/2
    • def est_height(g,d,m):
    • return(d+m+1)/2if g=="boy"else(d+m-1)/2
Code
Diff
  • use rand::prelude::*;
    
    const SPECIAL_CHARACTERS: [char; 39] = [
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
        '.', ',', ':', ';', '<', '>', '?', '+', '-', '=',
        '/', '\\', '\'', '"', '{', '}', '[', ']', '_'
    ];
    
    fn password_from_phrase(phrase: &str) -> String {
        let mut rng = rand::thread_rng();
        let mut phrase: Vec<_> = phrase
            .chars()
            .filter(|c| c.is_ascii_alphabetic())
            .map(|c| c.to_ascii_lowercase())
            .collect();
        phrase.shuffle(&mut rng);
        phrase.into_iter()
            .chain((0..10).map(|_| *SPECIAL_CHARACTERS.choose(&mut rng).unwrap()))
            .collect()
    }
    • import random
    • import string
    • def password_from_phrase(phrase):
    • # Remove any non-alphabetic characters and convert to lowercase
    • phrase = ''.join(filter(str.isalpha, phrase)).lower()
    • # Shuffle the characters in the phrase
    • phrase_chars = list(phrase)
    • random.shuffle(phrase_chars)
    • shuffled_phrase = ''.join(phrase_chars)
    • # Generate a random string of numbers and symbols
    • num_symbols = random.randint(6, 10)
    • symbols = ''.join(random.choices(string.punctuation, k=num_symbols))
    • # Combine the shuffled phrase and symbols to form the password
    • password = shuffled_phrase[:6] + symbols + shuffled_phrase[6:]
    • return password
    • use rand::prelude::*;
    • const SPECIAL_CHARACTERS: [char; 39] = [
    • '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    • '!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
    • '.', ',', ':', ';', '<', '>', '?', '+', '-', '=',
    • '/', '\\', '\'', '"', '{', '}', '[', ']', '_'
    • ];
    • fn password_from_phrase(phrase: &str) -> String {
    • let mut rng = rand::thread_rng();
    • let mut phrase: Vec<_> = phrase
    • .chars()
    • .filter(|c| c.is_ascii_alphabetic())
    • .map(|c| c.to_ascii_lowercase())
    • .collect();
    • phrase.shuffle(&mut rng);
    • phrase.into_iter()
    • .chain((0..10).map(|_| *SPECIAL_CHARACTERS.choose(&mut rng).unwrap()))
    • .collect()
    • }

Write a function that returns "Hello World baby" if its true and "No World" if its false

Code
Diff
  • /*def hello_world(world):
        if world == True:
            return "Hello World baby"
        elif world == False:
            return "No World"*/
    
    // helloWorld = (world) => world == true ? 'Hello World baby': 'No World';
    
    const helloWorld=(world)=>world ?`Hello World baby`:`No World`;
    • /*def hello_world(world):
    • if world == True:
    • return "Hello World baby"
    • elif world == False:
    • return "No World"*/
    • // helloWorld = (world) => world == true ? 'Hello World baby': 'No World';
    • const helloWorld=(world)=>world==true?`Hello World baby`:`No World`;
    • const helloWorld=(world)=>world ?`Hello World baby`:`No World`;