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
  • def test() :
        word = "test"
        return f"{word}"
    • def test() :
    • return "test"
    • word = "test"
    • return f"{word}"
Code
Diff
  • def multiply(a,b):
        return a*b
    
    result = multiply(5, 10)
    print(result)
    
    • from math import prod
    • def multiply(a, b):
    • ints = (a, b)
    • return prod(ints)
    • def multiply(a,b):
    • return a*b
    • result = multiply(5, 10)
    • print(result)
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`;
Code
Diff
  • fn vector_multiply(input: &[i32]) -> i32 {
        input.iter().product()
    }
    • fn vector_multiply(input: Vec<i32>) -> i32 {
    • input.iter()
    • .product()
    • fn vector_multiply(input: &[i32]) -> i32 {
    • input.iter().product()
    • }
Strings
Ciphers
Fundamentals
Cryptography
Algorithms
Code
Diff
  • fn encode(phrase: &str, key: &str) -> String {
        apply_modifier(phrase, key, |(character, offset)| character + offset)
    }
    
    fn decode(phrase: &str, key: &str) -> String {
        apply_modifier(phrase, key, |(character, offset)| character - offset)
    }
    
    fn apply_modifier(phrase: &str, key: &str, f: fn((u8, u8)) -> u8) -> String {
        phrase.chars()
            .map(normalize) // 'A'..='Z' and 'a'..='z' to 0..26 and 26..52
            .map(|n| n + 52) // 0..52 to 52..104 so that subtraction doesn't overflow
            .zip(offsets(key).into_iter().cycle()) // generate and cycle over the offsets
            .map(|n| f(n) % 52) // apply encoding/decoding and remainder it back to 0..52
            .map(denormalize) // 0..26 and 26..52 to 'A'..='Z' and 'a'..='z'
            .collect()
    }
    
    fn normalize(character: char) -> u8 {
        character as u8 - if character.is_ascii_uppercase() { b'A' } else { b'a' - 26 }
    }
    
    fn denormalize(normalized: u8) -> char {
        (normalized + if normalized < 26 { b'A' } else { b'a' - 26 }) as char
    }
    
    fn offsets(key: &str) -> Vec<u8> {
        let key_len = key.len() as u8;
        let offsets: Vec<_> = key.chars().map(move |ch| ch as u8 % 10 + key_len).collect();
        if offsets.is_empty() {
            vec![0]
        } else {
            offsets
        }
    }
    • public class Kata {
    • public static String encode(String phrase, String key) {
    • return "";
    • }
    • public static String decode(String phrase, String key) {
    • return "";
    • }
    • fn encode(phrase: &str, key: &str) -> String {
    • apply_modifier(phrase, key, |(character, offset)| character + offset)
    • }
    • fn decode(phrase: &str, key: &str) -> String {
    • apply_modifier(phrase, key, |(character, offset)| character - offset)
    • }
    • fn apply_modifier(phrase: &str, key: &str, f: fn((u8, u8)) -> u8) -> String {
    • phrase.chars()
    • .map(normalize) // 'A'..='Z' and 'a'..='z' to 0..26 and 26..52
    • .map(|n| n + 52) // 0..52 to 52..104 so that subtraction doesn't overflow
    • .zip(offsets(key).into_iter().cycle()) // generate and cycle over the offsets
    • .map(|n| f(n) % 52) // apply encoding/decoding and remainder it back to 0..52
    • .map(denormalize) // 0..26 and 26..52 to 'A'..='Z' and 'a'..='z'
    • .collect()
    • }
    • fn normalize(character: char) -> u8 {
    • character as u8 - if character.is_ascii_uppercase() { b'A' } else { b'a' - 26 }
    • }
    • fn denormalize(normalized: u8) -> char {
    • (normalized + if normalized < 26 { b'A' } else { b'a' - 26 }) as char
    • }
    • fn offsets(key: &str) -> Vec<u8> {
    • let key_len = key.len() as u8;
    • let offsets: Vec<_> = key.chars().map(move |ch| ch as u8 % 10 + key_len).collect();
    • if offsets.is_empty() {
    • vec![0]
    • } else {
    • offsets
    • }
    • }