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

try to format the code properly

Code
Diff
  • fun returnNum(n: Int) = n
    
    • fun returnNum(n:Int)=n
    • fun returnNum(n: Int) = n
Code
Diff
  • def multiply_and_add_one(a, b):
        r = 0
        for i in range(b):
            r += a
        r += 1
        
        if False:
            return r
        else:
            return r
    
    • def multiply_and_add_one(a, b):
    • r = 0
    • for i in range(b):
    • r += a
    • r += 1
    • return r
    • if False:
    • return r
    • else:
    • return r

Correction of the algorithme

Code
Diff
  • import re
    
    def count(text: str) -> int:
        pattern = r"[aeiouyAEIOUY]"
    
         # Find all vowel matches in the string/text
        matches = re.findall(pattern, text)
    
        # Return the number of vowels
        return len(matches)
    • import re
    • def count(text: str) -> int:
    • ctr = 0
    • vowels = ['a', 'e', 'i', 'o', 'u']
    • for letter in text:
    • if letter.lower() in vowels:
    • ctr += 1
    • pattern = r"[aeiouyAEIOUY]"
    • # Find all vowel matches in the string/text
    • matches = re.findall(pattern, text)
    • return ctr
    • # Return the number of vowels
    • return len(matches)
Code
Diff
  • def morse_code(msg: str) -> str:
        
        MORSE_DICT = {
            'a': '.-',      'b': '-...',    'c': '-.-.', 
            'd': '-..',     'e': '.',       'f': '..-.',
            'g': '--.',     'h': '....',    'i': '..',
            'j': '.---',    'k': '-.-',     'l': '.-..',
            'm': '--',      'n': '-.',      'o': '---',
            'p': '.--.',    'q': '--.-',    'r': '.-.',
            's': '...',     't': '-',       'u': '..-',
            'v': '...-',    'w': '.--',     'x': '-..-',
            'y': '-.--',    'z': '--..',    '0': '-----',
            '1': '.----',   '2': '..---',   '3': '...--',
            '4': '....-',   '5': '.....',   '6': '-....',
            '7': '--...',   '8': '---..',   '9': '----.',
            '.': '.-.-.-',  ',': '--..--',  "'": '.----.',
            '?': '..--..',  ':': '---...',  '-': '-....-',
            '/': '-..-.',   '[': '-.--.',   '(': '-.--.',
            ']': '-.--.-',  ')': '-.--.-',  '"': '.-..-.',
            '_': '..--.-',  '=': '-...-',   '+': '.-.-.',
            '@': '.--.-.',  '!': '-.-.--',  ' ': '/'
        }
    
        return ' '.join(
            MORSE_DICT[char] 
            for char in msg.casefold() 
            if char in MORSE_DICT
        )
    • def morse_code(msg):
    • """Morse Code function"""
    • morse_dict = {
    • 'a': '.-',
    • 'b': '-...',
    • 'c': '-.-.',
    • 'd': '-..',
    • 'e': '.',
    • 'f': '..-.',
    • 'g': '--.',
    • 'h': '....',
    • 'i': '..',
    • 'j': '.---',
    • 'k': '-.-',
    • 'l': '.-..',
    • 'm': '--',
    • 'n': '-.',
    • 'o': '---',
    • 'p': '.--.',
    • 'q': '--.-',
    • 'r': '.-.',
    • 's': '...',
    • 't': '-',
    • 'u': '..-',
    • 'v': '...-',
    • 'w': '.--',
    • 'x': '-..-',
    • 'y': '-.--',
    • 'z': '--..',
    • '0': '-----',
    • '1': '.----',
    • '2': '..---',
    • '3': '...--',
    • '4': '....-',
    • '5': '.....',
    • '6': '-....',
    • '7': '--...',
    • '8': '---..',
    • '9': '----.',
    • '.': '.-.-.-',
    • ',': '--..--',
    • "'": '.----.',
    • '?': '..--..',
    • ':': '---...',
    • '-': '-....-',
    • '/': '-..-.',
    • '[': '-.--.',
    • '(': '-.--.',
    • ']': '-.--.-',
    • ')': '-.--.-',
    • '"': '.-..-.',
    • '_': '..--.-',
    • '=': '-...-',
    • '+': '.-.-.',
    • '@': '.--.-.',
    • '!': '-.-.--',
    • ' ': '/'
    • def morse_code(msg: str) -> str:
    • MORSE_DICT = {
    • 'a': '.-', 'b': '-...', 'c': '-.-.',
    • 'd': '-..', 'e': '.', 'f': '..-.',
    • 'g': '--.', 'h': '....', 'i': '..',
    • 'j': '.---', 'k': '-.-', 'l': '.-..',
    • 'm': '--', 'n': '-.', 'o': '---',
    • 'p': '.--.', 'q': '--.-', 'r': '.-.',
    • 's': '...', 't': '-', 'u': '..-',
    • 'v': '...-', 'w': '.--', 'x': '-..-',
    • 'y': '-.--', 'z': '--..', '0': '-----',
    • '1': '.----', '2': '..---', '3': '...--',
    • '4': '....-', '5': '.....', '6': '-....',
    • '7': '--...', '8': '---..', '9': '----.',
    • '.': '.-.-.-', ',': '--..--', "'": '.----.',
    • '?': '..--..', ':': '---...', '-': '-....-',
    • '/': '-..-.', '[': '-.--.', '(': '-.--.',
    • ']': '-.--.-', ')': '-.--.-', '"': '.-..-.',
    • '_': '..--.-', '=': '-...-', '+': '.-.-.',
    • '@': '.--.-.', '!': '-.-.--', ' ': '/'
    • }
    • return ' '.join([morse_dict.get(letter) for letter in msg])
    • return ' '.join(
    • MORSE_DICT[char]
    • for char in msg.casefold()
    • if char in MORSE_DICT
    • )
Code
Diff
  • def above_two(n):
        return n > 2
    • above_two = lambda number: number > 2
    • def above_two(n):
    • return n > 2
Code
Diff
  • "pick four digit number"
    "scatter the numbers randomly"
    "select number"
    "then what"
    "then we redo the process and spam emails with the result"
    "Hahaha ridiculous kumite"
    • "pick four digit number"
    • "scatter the numbers randomly"
    • "select number"
    • "then what"
    • "then we redo the process and spam emails with the result"
    • "then we redo the process and spam emails with the result"
    • "Hahaha ridiculous kumite"