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
Code
Diff
  • feed_the_primates_v1 = lambda a,f: [['🍌']*len(list(filter({"🐒","🦍"}.__contains__, a))), 'No bananas!'][f.count("🍌") == 0] 
    feed_the_primates_v2 = lambda a,f: 'No bananas!' if "🍌" not in set(f) else ["🍌" for m in a if m in {"🐒", "🦍"} and "🍌" in f]
    • feed_the_primates_v1 = lambda a,f: 'No bananas!' if "🍌" not in set(f) else ["🍌" for m in a if m in {"🐒", "🦍"} and "🍌" in f]
    • banana = "🍌"
    • feed_the_primates_v2 = lambda a,f: 'No bananas!' if banana not in set(f) else [banana for m in a if m in {"🐒", "🦍"} and banana in f]
    • # other option being: replacing banana as inline value
    • feed_the_primates_v1 = lambda a,f: [['🍌']*len(list(filter({"🐒","🦍"}.__contains__, a))), 'No bananas!'][f.count("🍌") == 0]
    • feed_the_primates_v2 = lambda a,f: 'No bananas!' if "🍌" not in set(f) else ["🍌" for m in a if m in {"🐒", "🦍"} and "🍌" in f]
Code
Diff
  • from random import getrandbits
    class Random_Bool(object):
        def __repr__(self): 
            return repr(self.r())
        
        def __init__(self): 
            
             self.r =  lambda: bool(getrandbits(1))
                
    random_boolean = Random_Bool()
    
    • from random import choice
    • from random import getrandbits
    • class Random_Bool(object):
    • def __repr__(self):
    • return repr(self.r())
    • def __init__(self):
    • self.r = lambda: choice([True,False])
    • self.r = lambda: bool(getrandbits(1))
    • random_boolean = Random_Bool()
Test Cases
Diff
  • rb = Random_Bool()
    print(rb.r())
    print(rb.r())
    print(rb.r())
    print(rb.r())
    • print(random_boolean)
    • print(random_boolean.r())
    • # or if you actually wanted to use this...
    • rb = Random_Bool()
    • print(rb.r())
    • print(rb.r())
    • print(rb.r())
    • print(rb.r())
Code
Diff
  • import os
    
    
    DIR = os.path.join(os.getcwd(), 'venv')
    
    
    def list_venv():
        """ List venv dirs and files """
        
        try:
            print((ve := os.listdir(DIR)))
            
            for x in ve:
                list_subs(x)
            
        except:
            print("Error: venv dir not found in the path")
        
    
    def list_subs(x):
        """ For files in venv, which will be (Libs, and Scripts) """
    
        try:
            # subdirs
            print(x, os.listdir(os.path.join(DIR, x)))
            
            for y in x:
                list_sub_sub(x, y)
                
        except:
            print_config(x)
            
                         
    def list_sub_sub(x, y):
        """ List subdirs and files in subdirs
        
        Warning: the next code was full of 
        `This does not get executed` messages """
        
        try:
            print(x, os.listdir(os.path.join(DIR, x, y)))
        
            for z in y:    
                try:
                    print_file(x, y)  # not y, z?
                    
                except:
                    print("...goes on...")
                    
        except:
            try:
                print_file_fallback(x)
                
            except:
                print("")  # This gets executed (the only one!)
                        
                    
    
    def print_file(x, y):
        with open(os.path.join(DIR, x, y), 'r') as file:
            print(file.read())
            
    
    def print_file_fallback(x):
        with open(os.path.join(DIR, x), 'r') as file:
            print(file.read())
            
            
    def print_config(x):
        """ This will get executed twice,  opening 
        the .gitignore, and pyvenv.cfg file """
            
        with open(os.path.join(DIR, x), 'r') as file:
            print(file.read())
            
            
    list_venv()
    
    • import os
    • DIR = os.path.join(os.getcwd(), 'venv')
    • def list_venv():
    • """ List venv dirs and files """
    • print((ve := os.listdir(DIR)))
    • for x in ve:
    • list_subs(x)
    • try:
    • print((ve := os.listdir(DIR)))
    • for x in ve:
    • list_subs(x)
    • except:
    • print("Error: venv dir not found in the path")
    • def list_subs(x):
    • """For files in venv, which will be (Libs, and Scripts) """
    • """ For files in venv, which will be (Libs, and Scripts) """
    • try:
    • # subdirs
    • print(x, os.listdir(os.path.join(DIR, x)))
    • for y in x:
    • list_sub_sub(x, y)
    • except:
    • print_config(x)
    • def print_config(x):
    • """ This will get executed twice, opening
    • the .gitignore, and pyvenv.cfg file """
    • with open(os.path.join(DIR, x), 'r') as file:
    • print(file.read())
    • def list_sub_sub(x, y):
    • """ Warning: the next code was full of
    • """ List subdirs and files in subdirs
    • Warning: the next code was full of
    • `This does not get executed` messages """
    • try:
    • print(x, os.listdir(os.path.join(DIR, x, y)))
    • for z in y:
    • try:
    • print_file(x, y) # not y, z?
    • except:
    • print("...goes on...")
    • except:
    • try:
    • print_file_fallback(x)
    • except:
    • print("") # This gets executed (the only one!)
    • def print_file(x, y):
    • with open(os.path.join(DIR, x, y), 'r') as file:
    • print(file.read())
    • def print_file_fallback(x):
    • with open(os.path.join(DIR, x), 'r') as file:
    • print(file.read())
    • def print_config(x):
    • """ This will get executed twice, opening
    • the .gitignore, and pyvenv.cfg file """
    • with open(os.path.join(DIR, x), 'r') as file:
    • print(file.read())
    • list_venv()
Code
Diff
  • module ToUpperFirst where
    
    import Data.Char
    import Data.List
        
    mapcap :: String -> String
    mapcap = concat . intersperse " " . fmap (\(l:ls) -> (toUpper l):ls) . words
    
    • module ToUpperFirst where
    • import Data.Char
    • import Data.Char
    • import Data.List
    • toUpperFirst "" = ""
    • toUpperFirst (x : xs) = (toUpper x) : xs
    • mapcap :: String -> String
    • mapcap = concat . intersperse " " . fmap (\(l:ls) -> (toUpper l):ls) . words