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
  • const reverseGear=w=>[...w].reverse().join``
    • const reverseGear=w=>[...w].reverse().join('')
    • const reverseGear=w=>[...w].reverse().join``
Code
Diff
  • fn remove_symbols(s: &str) -> String {
        s.chars().filter(|c| c.is_alphabetic() || c.is_whitespace()).collect()
    }
    
    • function removeSymbols(str) {
    • let newStr = "";
    • // list of possible symbols
    • const symbols = "@#$%&=^*()-_=+<>/[]|?!,.£`".split("");
    • // iterate through each characters in the input str, ignore character if it is a symbol
    • for (const char of str){
    • if (!symbols.includes(char)){
    • newStr += char;
    • }
    • }
    • // return new string with no symbols
    • return (newStr);
    • }
    • fn remove_symbols(s: &str) -> String {
    • s.chars().filter(|c| c.is_alphabetic() || c.is_whitespace()).collect()
    • }
Functional Programming

added translation for \n

Code
Diff
  • exec(f"{[].__doc__[26]}{ZeroDivisionError.__doc__[21]}{type({None}).__name__[1]}{type(1.0).__name__[0]} {(None,).__class__.__name__[2]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}{type(1).__name__[0]}{dict.__doc__[15] }{type({None}).__name__[1]}_{type(1.0).__name__[0]}{type(1.0).__name__[3]}{str(print.__module__.__class__)[1]}{type(str(), (), {}).__bases__[0].__name__[-1]}{type(1.0).__name__[2]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}{str.__name__[0]}({type(1).__name__[1]}):{[].__doc__[26]}    {ZeroDivisionError.__doc__[21]}{type(1).__name__[0]}{property.__doc__[77]}{type(1).__name__[0]}{ZeroDivisionError.__doc__[21]}{type({None}).__name__[1]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]} = {type(1.0).__name__[1]}{type(1.0).__name__[3]}{dict.__doc__[15] }{type(True).__name__[0]}{ZeroDivisionError.__doc__[21]}{type(1.0).__name__[3]} {list(zip(enumerate(type(().__class__.__subclasses__()).__dict__)))[28][0][1][1] }: {type(1).__name__[1]}{type({None}).__name__[1]}{list(zip(enumerate(type(().__class__.__subclasses__()).__dict__)))[28][0][1][1] }{type(str(), (), {}).__bases__[0].__name__[-1]}(({type(1).__name__[0]} {type(1.0).__name__[0]}{type(1.0).__name__[2]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]} {type(1).__name__[0]} {type(1).__name__[0]}{type(1).__name__[1]} {().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}{type(1.0).__name__[3]}{type(1).__name__[1]}{globals.__name__[0]}{type({None}).__name__[1]}(2, {list(zip(enumerate(type(().__class__.__subclasses__()).__dict__)))[28][0][1][1] }) {type(1).__name__[0]}{type(1.0).__name__[0]} {list(zip(enumerate(type(().__class__.__subclasses__()).__dict__)))[28][0][1][1] } % {type(1).__name__[0]} == 0), -1){[].__doc__[26]}{[].__doc__[26]}    {().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}{type({None}).__name__[1]}{type(str(), (), {}).__bases__[0].__name__[-1]}{(None,).__class__.__name__[1]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}{type(1).__name__[1]} ([] {type(1).__name__[0]}{type(1.0).__name__[0]} {type(1).__name__[1]} == 1 {type({None}).__name__[1]}{type(1.0).__name__[1]}{str.__name__[0]}{type({None}).__name__[1]} [{type(1).__name__[1]}]) {type(1).__name__[0]}{type(1.0).__name__[0]} {ZeroDivisionError.__doc__[21]}{type(1).__name__[0]}{property.__doc__[77]}{type(1).__name__[0]}{ZeroDivisionError.__doc__[21]}{type({None}).__name__[1]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}({type(1).__name__[1]}) == -1 {type({None}).__name__[1]}{type(1.0).__name__[1]}{str.__name__[0]}{type({None}).__name__[1]} ([{ZeroDivisionError.__doc__[21]}{type(1).__name__[0]}{property.__doc__[77]}{type(1).__name__[0]}{ZeroDivisionError.__doc__[21]}{type({None}).__name__[1]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}({type(1).__name__[1]})] + {(None,).__class__.__name__[2]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}{type(1).__name__[0]}{dict.__doc__[15] }{type({None}).__name__[1]}_{type(1.0).__name__[0]}{type(1.0).__name__[3]}{str(print.__module__.__class__)[1]}{type(str(), (), {}).__bases__[0].__name__[-1]}{type(1.0).__name__[2]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}{str.__name__[0]}({type(1).__name__[1]} // {ZeroDivisionError.__doc__[21]}{type(1).__name__[0]}{property.__doc__[77]}{type(1).__name__[0]}{ZeroDivisionError.__doc__[21]}{type({None}).__name__[1]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}({type(1).__name__[1]}))){[].__doc__[26]}")
    • fn prime_factors(n: u32) -> Vec<u32> {
    • let factors: Vec<u32> = (2..=n).filter(|i| n % i == 0).collect();
    • return factors
    • .into_iter()
    • .take_while(|i| i * i <= n)
    • .find(|x| n % x == 0)
    • .map(|i| {
    • let mut sub_factors = vec![i];
    • sub_factors.extend(prime_factors(n / i));
    • sub_factors
    • })
    • .unwrap_or(vec![n])
    • }
    • exec(f"{[].__doc__[26]}{ZeroDivisionError.__doc__[21]}{type({None}).__name__[1]}{type(1.0).__name__[0]} {(None,).__class__.__name__[2]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}{type(1).__name__[0]}{dict.__doc__[15] }{type({None}).__name__[1]}_{type(1.0).__name__[0]}{type(1.0).__name__[3]}{str(print.__module__.__class__)[1]}{type(str(), (), {}).__bases__[0].__name__[-1]}{type(1.0).__name__[2]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}{str.__name__[0]}({type(1).__name__[1]}):{[].__doc__[26]} {ZeroDivisionError.__doc__[21]}{type(1).__name__[0]}{property.__doc__[77]}{type(1).__name__[0]}{ZeroDivisionError.__doc__[21]}{type({None}).__name__[1]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]} = {type(1.0).__name__[1]}{type(1.0).__name__[3]}{dict.__doc__[15] }{type(True).__name__[0]}{ZeroDivisionError.__doc__[21]}{type(1.0).__name__[3]} {list(zip(enumerate(type(().__class__.__subclasses__()).__dict__)))[28][0][1][1] }: {type(1).__name__[1]}{type({None}).__name__[1]}{list(zip(enumerate(type(().__class__.__subclasses__()).__dict__)))[28][0][1][1] }{type(str(), (), {}).__bases__[0].__name__[-1]}(({type(1).__name__[0]} {type(1.0).__name__[0]}{type(1.0).__name__[2]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]} {type(1).__name__[0]} {type(1).__name__[0]}{type(1).__name__[1]} {().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}{type(1.0).__name__[3]}{type(1).__name__[1]}{globals.__name__[0]}{type({None}).__name__[1]}(2, {list(zip(enumerate(type(().__class__.__subclasses__()).__dict__)))[28][0][1][1] }) {type(1).__name__[0]}{type(1.0).__name__[0]} {list(zip(enumerate(type(().__class__.__subclasses__()).__dict__)))[28][0][1][1] } % {type(1).__name__[0]} == 0), -1){[].__doc__[26]}{[].__doc__[26]} {().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}{type({None}).__name__[1]}{type(str(), (), {}).__bases__[0].__name__[-1]}{(None,).__class__.__name__[1]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}{type(1).__name__[1]} ([] {type(1).__name__[0]}{type(1.0).__name__[0]} {type(1).__name__[1]} == 1 {type({None}).__name__[1]}{type(1.0).__name__[1]}{str.__name__[0]}{type({None}).__name__[1]} [{type(1).__name__[1]}]) {type(1).__name__[0]}{type(1.0).__name__[0]} {ZeroDivisionError.__doc__[21]}{type(1).__name__[0]}{property.__doc__[77]}{type(1).__name__[0]}{ZeroDivisionError.__doc__[21]}{type({None}).__name__[1]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}({type(1).__name__[1]}) == -1 {type({None}).__name__[1]}{type(1.0).__name__[1]}{str.__name__[0]}{type({None}).__name__[1]} ([{ZeroDivisionError.__doc__[21]}{type(1).__name__[0]}{property.__doc__[77]}{type(1).__name__[0]}{ZeroDivisionError.__doc__[21]}{type({None}).__name__[1]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}({type(1).__name__[1]})] + {(None,).__class__.__name__[2]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}{type(1).__name__[0]}{dict.__doc__[15] }{type({None}).__name__[1]}_{type(1.0).__name__[0]}{type(1.0).__name__[3]}{str(print.__module__.__class__)[1]}{type(str(), (), {}).__bases__[0].__name__[-1]}{type(1.0).__name__[2]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}{str.__name__[0]}({type(1).__name__[1]} // {ZeroDivisionError.__doc__[21]}{type(1).__name__[0]}{property.__doc__[77]}{type(1).__name__[0]}{ZeroDivisionError.__doc__[21]}{type({None}).__name__[1]}{().__class__.__bases__[0].__subclasses__()[40].__name__[-1]}({type(1).__name__[1]}))){[].__doc__[26]}")

Changes

  • the function now only accepts references to the input cuz duh
  • the types has to implement copy so basically all integers from the standard library (RIP bigint)
Code
Diff
  • use num::Num;
    
    fn sum<'a, S>(arr: impl IntoIterator<Item = &'a S>) -> S where S: 'a + Num + Copy {
        let mut sum = S::zero();
        for i in arr {
            sum = sum + *i;
        }
        return sum;
    }
    • use std::iter::Sum;
    • use num::Num;
    • fn sum<T, S>(arr: T) -> S where T: IntoIterator<Item = S>, S: Sum {
    • return arr.into_iter().sum();
    • fn sum<'a, S>(arr: impl IntoIterator<Item = &'a S>) -> S where S: 'a + Num + Copy {
    • let mut sum = S::zero();
    • for i in arr {
    • sum = sum + *i;
    • }
    • return sum;
    • }