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.

Code
Diff
  • def multiply_and_add_one(a, b):
        r = 0
        
        while b != 0:
            r += a if b & 1 else 0
            
            a <<= 1
            b >>= 1
            
        return r + 1
    • multiply_and_add_one = lambda a, b: a * b + 1
    • def multiply_and_add_one(a, b):
    • r = 0
    • while b != 0:
    • r += a if b & 1 else 0
    • a <<= 1
    • b >>= 1
    • return r + 1

Se a ou b não é uma letra, retorna -1, caso contrário, retorna 1 se estes dois argumentos estivem na mesma "caixa" ("caixa alta" ou "caixa baixa").

Code
Diff
  • public class Kata
    {
        public static int SameCase(char a, char b)
        {
            return !char.IsLetter(a) || !char.IsLetter(b) ? -1 : char.IsUpper(a) == char.IsUpper(b) ? 1 : 0;
        }
    }
    
    • public class Kata
    • {
    • public static int SameCase(char a, char b)
    • {
    • return (char.IsUpper(a) && char.IsUpper(b)) || (char.IsLower(a) && char.IsLower(b)) ? 1 : 0;
    • return !char.IsLetter(a) || !char.IsLetter(b) ? -1 : char.IsUpper(a) == char.IsUpper(b) ? 1 : 0;
    • }
    • }
Code
Diff
  • add=lambda x:x + x#look at the test case
         
    • add=lambda x:x #look at the test case
    • add=lambda x:x + x#look at the test case
Code
Diff
  • module MaxNum (maxNum) where
    
    import Data.List
    import Data.Ord
    
    maxNum :: Int -> Int
    maxNum = read . sortOn Down . show
    • module MaxNum (maxNum) where
    • import Data.List
    • import Data.Ord
    • maxNum :: Int -> Int
    • maxNum = read . reverse . sort . show
    • maxNum = read . sortOn Down . show

Oh you know what? nevermind...

Code
Diff
  • slow_sum=sum
    • slow_sum=lambda l:sum(l)
    • slow_sum=sum

no need to assign strlen to a seperate variable, saved some cycles.

Code
Diff
  • #include <stdlib.h>
    #include <string.h>
    #include <ctype.h>
    
    char *fun(const char *input)
    {
      char *result = malloc(strlen(input) + 1);
      char *p      = result;
      while (*p++ = toupper(*input++));
      return result;
    }
    • #include <stdlib.h>
    • #include <string.h>
    • #include <ctype.h>
    • char *fun(const char *input) {
    • size_t len = strlen(input);
    • char *result = malloc(len + 1);
    • char *p = result;
    • while ((*p++ = toupper(*input++)));
    • return result;
    • char *fun(const char *input)
    • {
    • char *result = malloc(strlen(input) + 1);
    • char *p = result;
    • while (*p++ = toupper(*input++));
    • return result;
    • }