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
Strings

Added proper handling of characters that expand when capitalized.

Ajouté la propre gestion des caractères qui se multiplient lorsqu'ils sont capitalisés.

Code
Diff
  • fn maestro_split(s: &str) -> String {
        let milieu = s.chars().count() / 2;
        let mut lettres = s.chars();
        let côté_gauche: String = (&mut lettres).take(milieu).flat_map(char::to_lowercase).collect();
        let lettre_majuscule = lettres.next().map(|c| c.to_uppercase().to_string()).unwrap_or_default();
        let côté_droite: String = lettres.flat_map(char::to_lowercase).collect();
        format!("{lettre_majuscule}{côté_droite}{côté_gauche}")
    }
    
    fn approche_naïf(s: &str) -> String {
        if s.is_empty() {
            return String::new();
        }
        let mid = s.len() / 2;
        format!("{}{}{}", s[mid..mid+1].to_uppercase(), s[mid+1..].to_lowercase(), s[..mid].to_lowercase())
    }
    • function maestroSplit(string) {
    • let newWord = string.slice(parseInt(string.length / 2)) + string.slice(0, parseInt(string.length / 2));
    • return newWord.toLowerCase().charAt(0).toUpperCase() + newWord.toLowerCase().slice(1);
    • fn maestro_split(s: &str) -> String {
    • let milieu = s.chars().count() / 2;
    • let mut lettres = s.chars();
    • let côté_gauche: String = (&mut lettres).take(milieu).flat_map(char::to_lowercase).collect();
    • let lettre_majuscule = lettres.next().map(|c| c.to_uppercase().to_string()).unwrap_or_default();
    • let côté_droite: String = lettres.flat_map(char::to_lowercase).collect();
    • format!("{lettre_majuscule}{côté_droite}{côté_gauche}")
    • }
    • fn approche_naïf(s: &str) -> String {
    • if s.is_empty() {
    • return String::new();
    • }
    • let mid = s.len() / 2;
    • format!("{}{}{}", s[mid..mid+1].to_uppercase(), s[mid+1..].to_lowercase(), s[..mid].to_lowercase())
    • }
Code
Diff
  • fn other_angle(angle1: u32, angle2: u32) -> u32 {
        180 - (angle1 + angle2)
    }
    • public class ThirdAngle {
    • public static int otherAngle(int angle1, int angle2) {
    • return 180-(angle1+angle2);
    • }
    • fn other_angle(angle1: u32, angle2: u32) -> u32 {
    • 180 - (angle1 + angle2)
    • }
Code
Diff
  • fn find_index(slice: &[i32], value: i32) -> Option<usize> {
        slice.iter().position(|&num| num == value)
    }
    • public class Kata {
    • public static int findIndex (int[] my_array, int t) {
    • // Find the index of t
    • return 4;
    • }
    • fn find_index(slice: &[i32], value: i32) -> Option<usize> {
    • slice.iter().position(|&num| num == value)
    • }

Given an array containing only 0s, 1s, and 2s; sort the array in ascending order.

Code
Diff
  • fn sort_values(slice: &[u8]) -> Vec<u8> {
        let mut counts = [0, 0, 0];
        for &num in slice {
            counts[num as usize] += 1;
        }
        counts
            .into_iter()
            .enumerate()
            .flat_map(|(num, count)| std::iter::repeat(num as u8).take(count))
            .collect()
    }
    • public class Kata {
    • public static int[] sortValues(int[] my_array, int size) {
    • // Given an array of size N containing only 0s, 1s, and 2s;
    • // sort the array in ascending order.
    • int[] returnArray = {0,0,0,0,1,1,2,2};
    • return returnArray;
    • fn sort_values(slice: &[u8]) -> Vec<u8> {
    • let mut counts = [0, 0, 0];
    • for &num in slice {
    • counts[num as usize] += 1;
    • }
    • counts
    • .into_iter()
    • .enumerate()
    • .flat_map(|(num, count)| std::iter::repeat(num as u8).take(count))
    • .collect()
    • }
Code
Diff
  • macro_rules! your_name {
        () => { your_name!("Taki") };
        ($name: expr) => { format!("Hello {}, you are very kool!", $name) };
    }
    • def your_name(n="Taki"):
    • return "Hello "+n+", you are very kool!"
    • macro_rules! your_name {
    • () => { your_name!("Taki") };
    • ($name: expr) => { format!("Hello {}, you are very kool!", $name) };
    • }
Fundamentals
Strings
Code
Diff
  • reverse_string = lambda string: string[::-1]
    • reverse_string = lambda string: __import__('functools').reduce(lambda a, b: b + a, string)
    • reverse_string = lambda string: string[::-1]
Code
Diff
  • fn shortest_word_length(s: &str) -> usize {
        s.split_whitespace().map(str::len).min().unwrap_or(0)
    }
    • import java.util.stream.*; public class Kata { public static int findShort(String s) { return Stream.of(s.split(" ")) .mapToInt(String::length) .min() .getAsInt(); } }
    • fn shortest_word_length(s: &str) -> usize {
    • s.split_whitespace().map(str::len).min().unwrap_or(0)
    • }
Fundamentals
Arrays
Strings
Code
Diff
  • object FindTRex:
      val containsTRex: Array[String] => Boolean = _.contains("Tyrannosaurus")
    
    • object FindTRex:
    • def containsTRex(things: Array[String]): Boolean = things.contains("Tyrannosaurus")
    • val containsTRex: Array[String] => Boolean = _.contains("Tyrannosaurus")
Code
Diff
  • fn lol() -> fn() -> fn() -> fn() -> u32 {
        fn lol() -> fn() -> fn() -> u32 {
            fn lol() -> fn() -> u32 {
                fn lol() -> u32 {
                    100
                }
                lol
            }
            lol
        }
        lol
    }
    • def n(n=100):
    • def lol():
    • def lol():
    • def lol():
    • nonlocal n
    • if n:
    • lol=lambda:100
    • return lol()
    • else:
    • return lol()
    • return lol
    • return lol
    • return lol()()()
    • fn lol() -> fn() -> fn() -> fn() -> u32 {
    • fn lol() -> fn() -> fn() -> u32 {
    • fn lol() -> fn() -> u32 {
    • fn lol() -> u32 {
    • 100
    • }
    • lol
    • }
    • lol
    • }
    • lol
    • }
Code
Diff
  • fn nand(a: bool, b: bool) -> bool {
        !(a && b)
    }
    
    fn not(a: bool) -> bool {
        nand(a, a)
    }
    
    fn and(a: bool, b: bool) -> bool {
        not(nand(a, b))
    }
    
    fn or(a: bool, b: bool) -> bool {
        nand(not(a), not(b))
    }
    
    fn nor(a: bool, b: bool) -> bool {
        not(or(a, b))
    }
    
    fn xor(a: bool, b: bool) -> bool {
        and(nand(a, b), or(a, b))
    }
    
    fn xnor(a: bool, b: bool) -> bool {
        not(xor(a, b))
    }
    • def NOT(a):
    • if a=="1":
    • return "0"
    • elif a=="0":
    • return "1"
    • def BUF(a):
    • if a=="1":
    • return "1"
    • elif a=="0":
    • return "0"
    • def AND(a,b):
    • if a=="1" and b=="1":
    • return "1"
    • else:
    • return "0"
    • def OR(a,b):
    • if a=="0" and b=="0":
    • return "0"
    • else:
    • return "1"
    • def NAND(a,b):
    • return NOT(AND(a,b))
    • fn nand(a: bool, b: bool) -> bool {
    • !(a && b)
    • }
    • def NOR(a,b):
    • return NOT(OR(a,b))
    • fn not(a: bool) -> bool {
    • nand(a, a)
    • }
    • def XOR(a,b):
    • return OR(AND(a,b),NOR(a,b))
    • fn and(a: bool, b: bool) -> bool {
    • not(nand(a, b))
    • }
    • def XNOR(a,b):
    • return NOT(XOR(a,b))
    • fn or(a: bool, b: bool) -> bool {
    • nand(not(a), not(b))
    • }
    • fn nor(a: bool, b: bool) -> bool {
    • not(or(a, b))
    • }
    • fn xor(a: bool, b: bool) -> bool {
    • and(nand(a, b), or(a, b))
    • }
    • fn xnor(a: bool, b: bool) -> bool {
    • not(xor(a, b))
    • }