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
  • console.log((n=>["Almost there","yuh gotta wait a little"][+(n>3)])(90))
    • let distance = 90; // try changing this value to test different outputs
    • output = distance < 3 ? "Almost there": "yuh gotta wait a little"
    • console.log(output);
    • console.log((n=>["Almost there","yuh gotta wait a little"][+(n>3)])(90))
Code
Diff
  • // патриотическая задача 1 22ФПИ1 Власова
    _ = (число_1, число_2, число_3) =>
    число_1>число_2?
      число_1>число_3?
      число_1:число_3
      :число_2>число_3?
      число_2:число_3
    • // патриотическая задача 1
    • _ = () =>
    • // патриотическая задача 1 22ФПИ1 Власова
    • _ = (число_1, число_2, число_3) =>
    • число_1>число_2?
    • число_1>число_3?
    • число_1:число_3
    • :число_2>число_3?
    • число_2:число_3
Code
Diff
  • //патриотическая задача 2 22фпи1 Зубарева Макеева
    _ = (_1,_3) => (_3==_1)?_1:_3+_(_1,_3-1);
    • _ = (_1,_2) =>
    • //патриотическая задача 2 22фпи1 Зубарева Макеева
    • _ = (_1,_3) => (_3==_1)?_1:_3+_(_1,_3-1);

Safe version because of not using an eval, yet still prone to errors like DivizionByZeroExcpetion or KeyError

Code
Diff
  • from operator import add, sub, mul, truediv
    
    def calculator(a, b, operator):
        return {'+': add, '-': sub, '*': mul, '/': truediv}[operator](a, b)
    
    • from operator import add, sub, mul, truediv
    • def calculator(a, b, operator):
    • if not isinstance(a, (int, float)) or not isinstance(b, (int, float)):
    • return "Operands must be numbers"
    • operations = {
    • '+': lambda x, y: x + y,
    • '-': lambda x, y: x - y,
    • '*': lambda x, y: x * y,
    • '/': lambda x, y: x / y if y != 0 else "Cannot divide by zero"
    • }
    • if operator not in operations:
    • return "Invalid operator"
    • return operations[operator](a, b)
    • return {'+': add, '-': sub, '*': mul, '/': truediv}[operator](a, b)
Code
Diff
  • import random
    import string
    
    '''
    ⠀⠀⠀⠀⠀⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⡄⠀⠀⠀⠀⠀
    ⠀⠀⠀⠀⢀⡿⣷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⠄⠀⠀⠀
    ⠀⠀⠀⠀⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡆⠀⠀⠀
    ⠀⠀⠀⢠⣿⣇⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠀⠀⠀
    ⠀⠀⠀⠀⣻⣿⣿⣿⣿⡿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣯⣟⣿⣿⣿⣿⣷⣭⠀⠀⠀
    ⠀⠀⠀⠀⣻⣿⠟⠛⠉⠁⠈⠉⠻⢿⣿⣿⣿⡟⠛⠂⠉⠁⠈⠉⠁⠻⣿⠀⠀⠀
    ⠀⠀⠀⠀⢾⠀⠀⣠⠄⠻⣆⠀⠈⠠⣻⣿⣟⠁⠀⠀⠲⠛⢦⡀⠀⠠⠁⠀⠀⠀
    ⠀⠀⠀⠀⢱⣄⡀⠘⠀⠸⠉⠀⠀⢰⣿⣷⣿⠂⢀⠀⠓⡀⠞⠀⢀⣀⠀⠀⠀⠀
    ⠀⠀⠀⠀⠠⣿⣷⣶⣶⣶⣾⣿⠀⠸⣿⣿⣿⣶⣿⣧⣴⣴⣶⣶⣿⡟⠀⠀⠀⠀
    ⠀⠀⠀⠀⠀⢿⣿⣿⣿⣿⣿⣏⠇⠄⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⣾⠁⠀⠀⠀⠀
    ⠀⠀⠀⠀⠀⢺⣿⣿⣿⣿⣟⡿⠂⠈⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠑⠀⠀⠀⠀⠀
    ⠀⠀⠀⠀⠀⠈⣿⣿⣿⣿⣿⠀⠀⠈⠿⣿⣿⣿⣿⣿⣿⣿⣿⠁⠀⠀⠀⠀⠀⠀
    ⠀⠀⠀⠀⠀⠄⢻⣿⣿⣿⡗⠀⠀⠀⠀⠈⠀⢨⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀
    ⠀⠀⠀⠀⠀⠀⡞⠷⠿⠿⠀⠀⠀⠀⢀⣘⣤⣿⣿⣿⣿⣿⡏⠀⠀⠀⠀⠀⠀⠀
    ⠀⠀⠀⠀⠀⠀⠼⠉⠀⠀⠀⠀⠀⠚⢻⠿⠟⠓⠛⠂⠉⠉⠁⠀⡁⠀⠀⠀⠀⠀
    ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣼⠀⠀⠀⠀⠀⠀
    ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⡿⡀⠀⠀⠀⠀⠀
    ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⢾⠻⠌⣄⡁⠀⠀⠀⠀⠀
    ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣀⣀⣀⡠⡲⠞⡁⠈⡈⣿⠀⠀⠀⠀⠀⠀
    ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠘⠛⠻⢯⠟⠩⠀⠀⢠⣣⠈⠀⠀⠀⠀⠀⠀
    ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠄⠂⣰⣧⣾⠶⠀⠀⠀⠀⠀⠀⠀
    '''
    
    
    def cursed_world():
        target = "hello world"
        letters = [random.choice(string.ascii_lowercase + ' ') for _ in range(11)]
    
        generation = 0
        while True:
            generation += 1
            score = sum(letters[i] == target[i] for i in range(11))
    
            if score == 11:
                return "".join(letters)
    
            new_letters = letters[:]
            for i in range(11):
                if new_letters[i] != target[i]:
                    if random.random() < 0.3:
                        new_letters[i] = random.choice(string.ascii_lowercase + ' ')
            letters = new_letters
            
            
    
    
    
    • import random
    • import string
    • '''
    • ⠀⠀⠀⠀⠀⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⡄⠀⠀⠀⠀⠀
    • ⠀⠀⠀⠀⢀⡿⣷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⠄⠀⠀⠀
    • ⠀⠀⠀⠀⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡆⠀⠀⠀
    • ⠀⠀⠀⢠⣿⣇⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠀⠀⠀
    • ⠀⠀⠀⠀⣻⣿⣿⣿⣿⡿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣯⣟⣿⣿⣿⣿⣷⣭⠀⠀⠀
    • ⠀⠀⠀⠀⣻⣿⠟⠛⠉⠁⠈⠉⠻⢿⣿⣿⣿⡟⠛⠂⠉⠁⠈⠉⠁⠻⣿⠀⠀⠀
    • ⠀⠀⠀⠀⢾⠀⠀⣠⠄⠻⣆⠀⠈⠠⣻⣿⣟⠁⠀⠀⠲⠛⢦⡀⠀⠠⠁⠀⠀⠀
    • ⠀⠀⠀⠀⢱⣄⡀⠘⠀⠸⠉⠀⠀⢰⣿⣷⣿⠂⢀⠀⠓⡀⠞⠀⢀⣀⠀⠀⠀⠀
    • ⠀⠀⠀⠀⠠⣿⣷⣶⣶⣶⣾⣿⠀⠸⣿⣿⣿⣶⣿⣧⣴⣴⣶⣶⣿⡟⠀⠀⠀⠀
    • ⠀⠀⠀⠀⠀⢿⣿⣿⣿⣿⣿⣏⠇⠄⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⣾⠁⠀⠀⠀⠀
    • ⠀⠀⠀⠀⠀⢺⣿⣿⣿⣿⣟⡿⠂⠈⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠑⠀⠀⠀⠀⠀
    • ⠀⠀⠀⠀⠀⠈⣿⣿⣿⣿⣿⠀⠀⠈⠿⣿⣿⣿⣿⣿⣿⣿⣿⠁⠀⠀⠀⠀⠀⠀
    • ⠀⠀⠀⠀⠀⠄⢻⣿⣿⣿⡗⠀⠀⠀⠀⠈⠀⢨⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀
    • ⠀⠀⠀⠀⠀⠀⡞⠷⠿⠿⠀⠀⠀⠀⢀⣘⣤⣿⣿⣿⣿⣿⡏⠀⠀⠀⠀⠀⠀⠀
    • ⠀⠀⠀⠀⠀⠀⠼⠉⠀⠀⠀⠀⠀⠚⢻⠿⠟⠓⠛⠂⠉⠉⠁⠀⡁⠀⠀⠀⠀⠀
    • ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣼⠀⠀⠀⠀⠀⠀
    • ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⡿⡀⠀⠀⠀⠀⠀
    • ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⢾⠻⠌⣄⡁⠀⠀⠀⠀⠀
    • ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣀⣀⣀⡠⡲⠞⡁⠈⡈⣿⠀⠀⠀⠀⠀⠀
    • ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠘⠛⠻⢯⠟⠩⠀⠀⢠⣣⠈⠀⠀⠀⠀⠀⠀
    • ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠄⠂⣰⣧⣾⠶⠀⠀⠀⠀⠀⠀⠀
    • '''
    • def cursed_world():
    • target = "hello world"
    • letters = [random.choice(string.ascii_lowercase + ' ') for _ in range(11)]
    • generation = 0
    • while True:
    • generation += 1
    • score = sum(letters[i] == target[i] for i in range(11))
    • if score == 11:
    • return "".join(letters)
    • new_letters = letters[:]
    • for i in range(11):
    • if new_letters[i] != target[i]:
    • if random.random() < 0.3:
    • new_letters[i] = random.choice(string.ascii_lowercase + ' ')
    • letters = new_letters
Code
Diff
  • когоБольше = (...группа) => {
    let девочка = -1;
    let мальчик = 1;
    
    let массив_девочек = [];
    let массив_мальчиков = [];
    for(item of группа){
      if(item<0){
        массив_девочек.push(item);
      } else if(item>0){
       массив_мальчиков.push(item);
      }
    }
      
    return массив_девочек.length> массив_мальчиков.length?`Девочек на ${массив_девочек.length- массив_мальчиков.length} больше`:
    массив_девочек.length< массив_мальчиков.length?`Девочек на ${массив_мальчиков.length- массив_девочек.length} меньше`:
    "Девочек и мальчиков равное количество";
     
    
    }
    • когоБольше = (...группа) => {
    • let девочка = -1;
    • let мальчик = 1;
    • let массив_девочек = [];
    • let массив_мальчиков = [];
    • for(item of группа){
    • if(item<0){
    • массив_девочек.push(item);
    • } else if(item>0){
    • массив_мальчиков.push(item);
    • }
    • }
    • return массив_девочек.length> массив_мальчиков.length?`Девочек на ${массив_девочек.length- массив_мальчиков.length} больше`:
    • массив_девочек.length< массив_мальчиков.length?`Девочек на ${массив_мальчиков.length- массив_девочек.length} меньше`:
    • "Девочек и мальчиков равное количество";
    • }
Code
Diff
  • local multiply_and_add_one = function(a, b)
        return a * b + 1
    end
    return multiply_and_add_one
    
    • def multiply_and_add_one(a, b):
    • return (a * b) + 1
    • local multiply_and_add_one = function(a, b)
    • return a * b + 1
    • end
    • return multiply_and_add_one
Code
Diff
  • function closestToZero(array $ints) {
         $closest = PHP_INT_MAX;
         if (empty($ints)) return 0;
         foreach ($ints as $item) {
            if (abs($closest) >= abs($item)) {
               $closest = $item;
            }
         }
         return $closest;
    }
    ?>
    • function closestToZero(array $ints) {
    • return 0;
    • $closest = PHP_INT_MAX;
    • if (empty($ints)) return 0;
    • foreach ($ints as $item) {
    • if (abs($closest) >= abs($item)) {
    • $closest = $item;
    • }
    • }
    • return $closest;
    • }
    • ?>

Just the same approch thre, but simplified it using chars, which turns a string into IntStream, allowing me to retrieve the sum easily. Then a simple comparison to get true or false.

Code
Diff
  • class Kata {
    
        public static String verifySum(String nameOne, String nameTwo) {
            if (nameOne == null || nameTwo == null) {
                return "NULL";
            }
    
            int sumOfNamesOne = nameOne.chars().sum();
            int sumOfNamesTwo = nameTwo.chars().sum();
    
            return sumOfNamesOne == sumOfNamesTwo ? "TRUE" : "FALSE";
        }
    }
    • class Kata{
    • public static String verifySum(String nameOne, String nameTwo) {
    • int[] sumOfNames = new int[]{0, 0};
    • class Kata {
    • public static String verifySum(String nameOne, String nameTwo) {
    • if (nameOne == null || nameTwo == null) {
    • return "NULL";
    • }
    • for (int i = 0; i < nameOne.length(); i++){
    • sumOfNames[0] += nameOne.charAt(i);
    • }
    • for (int i = 0; i < nameTwo.length(); i++){
    • sumOfNames[1] += nameTwo.charAt(i);
    • }
    • return sumOfNames[0] == sumOfNames[1] ? "TRUE" : "FALSE";
    • int sumOfNamesOne = nameOne.chars().sum();
    • int sumOfNamesTwo = nameTwo.chars().sum();
    • return sumOfNamesOne == sumOfNamesTwo ? "TRUE" : "FALSE";
    • }
    • }