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

look ma, only one space!

Code
Diff
  • result=lambda _:[_//10,'fail'][_<70]
    • result = lambda n: (n > 70) * n // 10 or 'fail'
    • result=lambda _:[_//10,'fail'][_<70]
Code
Diff
  • import operator as op
    print(f"{chr((not False)*5*~~~~~~~~~~~~~~True*20+4)}{chr(101)}{chr(108)}{chr(108)}{chr(111)}")
    • print("hello world")
    • import operator as op
    • print(f"{chr((not False)*5*~~~~~~~~~~~~~~True*20+4)}{chr(101)}{chr(108)}{chr(108)}{chr(111)}")
Fundamentals
Restricted

~

Code
Diff
  • is_even=lambda*x:~x[False]&True
    • is_even=lambda*x:not(x[False]&True)
    • is_even=lambda*x:~x[False]&True

a more maximalist version with type annotations like a java programmer who is learning python. But wait... a twist, mypy doesn't like this if you check the type annotations, a really good writeup of the issue can be found here: https://stackoverflow.com/questions/69334475/how-to-hint-at-number-types-i-e-subclasses-of-number-not-numbers-themselv/69383462#69383462. I hope I get to share this bit of serendipity with someone one day.

Code
Diff
  • from numbers import Number
    def kube (l: Number, w: Number, h: Number) -> Number:
        if any(not isinstance(x, Number) for x in (l, w, h)):
            raise TypeError("sides must be numeric")  
        if any(x < 0 for x in (l, w, h)):
            raise ValueError("Cube edges must have positive length")  
        else:
            return l * w * h
    • kube = lambda l, w, h: "Invalid Cube" if any(x < 0 for x in (l, w, h)) else l * w * h
    • from numbers import Number
    • def kube (l: Number, w: Number, h: Number) -> Number:
    • if any(not isinstance(x, Number) for x in (l, w, h)):
    • raise TypeError("sides must be numeric")
    • if any(x < 0 for x in (l, w, h)):
    • raise ValueError("Cube edges must have positive length")
    • else:
    • return l * w * h
Code
Diff
  • cap = lambda *a: -sum((-sum(a), min(a), max(a)))
    • def cap(low, high, num):
    • x, y = min(low, high, num), max(low, high, num)
    • return sum([low, high, num]) - sum([x, y])
    • cap = lambda *a: -sum((-sum(a), min(a), max(a)))
Code
Diff
  • public class Kata {
      public static int SameCase(char a, char b) => (char.IsLower(a)&&char.IsLower(b)||char.IsUpper(a)&&char.IsUpper(b))? 1 : (char.IsLetter(a)&&char.IsLetter(b))? 0 : -1;
    }
    • public class Kata {
    • public static int SameCase(char a, char b) {
    • string letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    • char tempA = a;
    • char tempB = b;
    • if((!letters.Contains(tempA = char.ToUpper(tempA)) && letters.Contains(tempB = char.ToUpper(tempB))) ||
    • (!letters.Contains(tempB = char.ToUpper(tempB)) && letters.Contains(tempA = char.ToUpper(tempA))) ||
    • (!letters.Contains(tempA = char.ToUpper(tempA)) && !letters.Contains(tempB = char.ToUpper(tempB)))) return -1;
    • if(char.IsUpper(a) && char.IsUpper(b)){
    • return 1;
    • } else if (char.IsLower(a) && char.IsLower(b)){
    • return 1;
    • } else {
    • return 0;
    • }
    • }
    • public static int SameCase(char a, char b) => (char.IsLower(a)&&char.IsLower(b)||char.IsUpper(a)&&char.IsUpper(b))? 1 : (char.IsLetter(a)&&char.IsLetter(b))? 0 : -1;
    • }