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
  • struct Person {
      first_name: String,
      last_name: String,
    }
    
    impl Person {
      fn greet(&self) -> String {
        format!("Hello, my name is {} {}", self.first_name, self.last_name)
      }
    }
    fn person_builder(first_name: &str, last_name: &str) -> Person {
        Person { first_name: first_name.to_owned(), last_name: last_name.to_owned() }
    }
    • // Code is in the preload
    • struct Person {
    • first_name: String,
    • last_name: String,
    • }
    • impl Person {
    • fn greet(&self) -> String {
    • format!("Hello, my name is {} {}", self.first_name, self.last_name)
    • }
    • }
    • fn person_builder(first_name: &str, last_name: &str) -> Person {
    • Person { first_name: first_name.into(), last_name: last_name.into() }
    • Person { first_name: first_name.to_owned(), last_name: last_name.to_owned() }
    • }

Scott numerals are slightly less slow than Church numerals in this kata

Code
Diff
  • const code = String.raw`
    # JohanWiltink
    
    B = \ f g x . f (g x)
    I = \ x . x
    K = \ x _ . x
    Y = \ f . ( \ x . f (x x) ) ( \ x . f (x x) )
    True = \ t f . t
    False = \ t f . f
    Succ = \ n z s . s n
    Pred = \ n . n 0 I
    Plus = \ m n . m n (B Succ (Plus n))
    Minus = \ m n . m 0 (B (n m) Minus)
    Times = \ m n . m 0 (B (Plus n) (Times n))
    isZero = \ n . n True (K False)
    isNotZero = \ n . n False (K True)
    And = \ x y . x y x
    Or = \ x . x x
    GT = \ x y . isNotZero (Minus x y)
    Mod = \ n m . ( \ r . isZero (Minus m r) 0 r ) (( \ n m . ( \ d . isZero d n (Mod d m) ) (Minus n m) ) n m)
    
    # function isPrime(n) {
    #   const trial = function trial(i) {
    #     return i * i > n || n % i != 0 && trial(i+1) ;
    #   } ;
    #   return n > 1 && trial(2) ;
    # }
    
    isPrime = \ n . ( \ trial . And (GT n 1) (trial 2) )
                    ( Y \ trial i . Or (GT (Times i i) n) (And (isNotZero (Mod n i)) (trial (Succ i))) )
    `
    • const code = String.raw`
    • # JohanWiltink
    • B = \ f g x . f (g x)
    • I = \ x . x
    • K = \ x _ . x
    • Y = \ f . ( \ x . f (x x) ) ( \ x . f (x x) )
    • True = \ t f . t
    • False = \ t f . f
    • Succ = \ n s z . s (n s z)
    • Pred = \ n s z . n ( \ f g . g (f s) ) (\_.z) \x.x
    • Minus = \ m n . n Pred m
    • Times = \ m n s . m (n s)
    • isZero = \ n . n (\_.False) True
    • isNotZero = \ n . n (\_.True) False
    • Succ = \ n z s . s n
    • Pred = \ n . n 0 I
    • Plus = \ m n . m n (B Succ (Plus n))
    • Minus = \ m n . m 0 (B (n m) Minus)
    • Times = \ m n . m 0 (B (Plus n) (Times n))
    • isZero = \ n . n True (K False)
    • isNotZero = \ n . n False (K True)
    • And = \ x y . x y x
    • Or = \ x . x x
    • GT = \ x y . isNotZero (Minus x y)
    • Mod = \ n m . ( \ r . isZero (Minus m r) 0 r ) (( \ n m . ( \ d . isZero d n (Mod d m) ) (Minus n m) ) n m)
    • # function isPrime(n) {
    • # const trial = function trial(i) {
    • # return i * i > n || n % i != 0 && trial(i+1) ;
    • # } ;
    • # return n > 1 && trial(2) ;
    • # }
    • isPrime = \ n . ( \ trial . And (GT n 1) (trial 2) )
    • ( Y \ trial i . Or (GT (Times i i) n) (And (isNotZero (Mod n i)) (trial (Succ i))) )
    • `
Code
Diff
  • def fizz_buzz(m):
        return ["Fizz"*int(n%3==0)+"Buzz"*int(n%5==0)  if (n%3==0 or n%5==0) else n for n in range(1,m)]
        
    • def fizz_buzz(n):
    • return ['FizzBuzz' if (i % 15 == 0) else 'Fizz' if(i % 3 == 0) else 'Buzz' if(i % 5 == 0) else i for i in range(1,n)]
    • def fizz_buzz(m):
    • return ["Fizz"*int(n%3==0)+"Buzz"*int(n%5==0) if (n%3==0 or n%5==0) else n for n in range(1,m)]
Basic Language Features
Fundamentals
Control Flow
Code
Diff
  • def convert_decimal_roman(number: int) -> str:
        try:
            number = int(number)
        except ValueError:
            print("Invalid Input, Value Error")
            return("Invalid Input")
        str = ''
        numDct = {1000: "M",
                  900: "CM",
                  500: "D",
                  400: "CD",
                  100: "C",
                  90: "XC",
                  50: "L",
                  40: "XL",
                  10: "X",
                  9: "IX",
                  5: "V",
                  4: "IV",
                  1: "I"}
        
        decimals = []
        for key, value in numDct.items():
            decimals.append(value * (number // key))
            number %= key
            
        return "".join(decimals)
    • def convert_decimal_roman(number):
    • def convert_decimal_roman(number: int) -> str:
    • try:
    • number = int(number)
    • except ValueError:
    • print("Invalid Input, Value Error")
    • return("Invalid Input")
    • str = ''
    • numDct = {1000: "M",
    • 900: "CM",
    • 500: "D",
    • 400: "CD",
    • 100: "C",
    • 90: "XC",
    • 50: "L",
    • 40: "XL",
    • 10: "X",
    • 9: "IX",
    • 5: "V",
    • 4: "IV",
    • 1: "I"}
    • decimals = []
    • for key, value in numDct.items():
    • str += value * (number // key)
    • decimals.append(value * (number // key))
    • number %= key
    • return str
    • return "".join(decimals)
Mathematics
Algorithms
Logic
Numbers
Code
Diff
  • from gmpy2 import is_prime as prime_checker
    • import re
    • def prime_checker(n):
    • return re.match(r'^1?$|^(11+?)\1+$', '1' * n) == None
    • from gmpy2 import is_prime as prime_checker
Strings
Data Types
Iterators
Control Flow
Object-oriented Programming
Basic Language Features
Fundamentals
Programming Paradigms
Code
Diff
  • def removeEverySecond(string):
        return string[::2]
    • removeEverySecond = lambda string: string[::2]
    • def removeEverySecond(string):
    • return string[::2]
Code
Diff
  • public class FizzBuzz
    {
        public string GetOutput(int number) {
          if (number % 15 == 0) return "FizzBuzz";
          else if (number % 3 == 0) return "Fizz";
          else if (number % 5 == 0) return "Buzz";
          else return number.ToString();
          // Fizz buzz is a popular computer science interview question.  
          // The function above is given a number - if the number is
          // divisible by 3, return "fizz", if it's divisible by 5, 
          // return "buzz", if not divisble by 3 or 5 - return the
          // number itself.
        }
    }
    • public class FizzBuzz
    • {
    • public string GetOutput(int number) {
    • if (number % 15 == 0) {
    • return "FizzBuzz";
    • }
    • else if (number % 3 == 0) {
    • return "Fizz";
    • }
    • else if (number % 5 == 0) {
    • return "Buzz";
    • }
    • else {
    • return number.ToString();
    • }
    • if (number % 15 == 0) return "FizzBuzz";
    • else if (number % 3 == 0) return "Fizz";
    • else if (number % 5 == 0) return "Buzz";
    • else return number.ToString();
    • // Fizz buzz is a popular computer science interview question.
    • // The function above is given a number - if the number is
    • // divisible by 3, return "fizz", if it's divisible by 5,
    • // return "buzz", if not divisble by 3 or 5 - return the
    • // number itself.
    • }
    • }