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
  • power
    
        =(b,e)=>
    
            !e||b==1?1:b**e
    • const power = (base,exp) => exp === 0 || base === 1 ? 1 : base**exp
    • power
    • =(b,e)=>
    • !e||b==1?1:b**e
Code
Diff
  • Module Kumite
        Public Function Min(array() As Single) As Single
            Return array.Min()
        End Function
    End Module 
    • Imports NUnit.Framework
    • Module Test
    • public function MinF(x, n)
    • dim min as integer
    • dim i as integer
    • min = x(0)
    • for i = 1 to n
    • if x(i) < min then
    • min = x(i)
    • end if
    • next
    • return min
    • end function
    • Module Kumite
    • Public Function Min(array() As Single) As Single
    • Return array.Min()
    • End Function
    • End Module
  • Introduced function chaining to reuse existing functions.
  • Introduced a base kwarg to override self.num as argument for the function for a more dynamic approach/higher reusability of existing functions.
Code
Diff
  • #!/usr/bin/env python3
    """
    Debugging: FixDatTrash # 2
    """
    
    # constant:
    PI = 3.1415926535897
    
    
    class Calculator:
        """A calculator class."""
    
        def __init__(self, num):
            """Initialize attributes."""
            self.num = num
    
        def calculate_power(self, exp, base=None):
            """
            Calculates power of self.num.
            parameter `exp` is the exponent.
            parameter `base` is an optional argument to override self.num with.
            """
            return (base or self.num) ** exp
    
        def calculate_square_root(self):
            """Calculates square root of self.num or any other real number."""
            return self.calculate_power(0.5)
    
        def calculate_cube_root(self):
            """Calculates cube root of self.num or any other real number."""
            return self.calculate_power(1 / 3)
    
        def calculate_circumference(self, base=None):
            """
            Calculates circumference of circle.
            self.num is the diameter of the circle.
            """
            return PI * (base or self.num)
        
        def calculate_circle_area(self):
            """
            Calculates area of circle.
            self.num is the radius of the circle.
            A=πr2
            """
            radius_squared = self.calculate_power(2)
            return self.calculate_circumference(radius_squared)
        
    • #!/usr/bin/env python3
    • """
    • Debugging: FixDatTrash # 2
    • """
    • import math
    • from dataclasses import dataclass
    • PI = math.pi
    • # constant:
    • PI = 3.1415926535897
    • @dataclass
    • class Calculator:
    • """A calculator class."""
    • num: int
    • def calculate_power(self, exp):
    • def __init__(self, num):
    • """Initialize attributes."""
    • self.num = num
    • def calculate_power(self, exp, base=None):
    • """
    • Calculates power of self.num.
    • parameter `exp` is the exponent.
    • parameter `base` is an optional argument to override self.num with.
    • """
    • return self.num ** exp
    • return (base or self.num) ** exp
    • def calculate_square_root(self):
    • """Calculates square root of self.num."""
    • return self.num ** 0.5
    • """Calculates square root of self.num or any other real number."""
    • return self.calculate_power(0.5)
    • def calculate_cube_root(self):
    • """Calculates cube root of self.num."""
    • return self.num ** (1 / 3)
    • """Calculates cube root of self.num or any other real number."""
    • return self.calculate_power(1 / 3)
    • def calculate_circumference(self):
    • def calculate_circumference(self, base=None):
    • """
    • Calculates circumference of circle.
    • self.num is the diameter of the circle.
    • """
    • return PI * self.num
    • return PI * (base or self.num)
    • def calculate_circle_area(self):
    • """
    • Calculates area of circle.
    • self.num is the radius of the circle
    • self.num is the radius of the circle.
    • A=πr2
    • """
    • return self.num ** 2 * PI
    • radius_squared = self.calculate_power(2)
    • return self.calculate_circumference(radius_squared)
Fundamentals
Logic

hey look I made it a code-golf one liner.

Code
Diff
  • using System;using System.Linq;public class Math{public static T Max<T>(params T[] param)where T:IComparable<T>{return param.Any()?param.Aggregate(param[0],(a,b)=>a.CompareTo(b)>0?a:b):default;}}  
    • using System;
    • using System.Linq;
    • public class Math
    • {
    • public static T Max<T>(params T[] param)
    • where T : IComparable<T>
    • {
    • return param.Any() ? param.Aggregate(param[0], (a, b) => a.CompareTo(b) > 0 ? a : b) : default;
    • }
    • }
    • using System;using System.Linq;public class Math{public static T Max<T>(params T[] param)where T:IComparable<T>{return param.Any()?param.Aggregate(param[0],(a,b)=>a.CompareTo(b)>0?a:b):default;}}
Code
Diff
  • const countVowel = str => --str.split(/[aeiou]/i).length;
    
    • const countVowel = str => str.split(/[aeiou]/i).length - 1
    • const countVowel = str => --str.split(/[aeiou]/i).length;
Code
Diff
  • package kata
    
    func MergeSort(data []int) []int {
    	if len(data) <= 1 {
    		return data
    	}
    
    	mid := len(data) / 2
    
    	return merge(MergeSort(data[:mid]), MergeSort(data[mid:]))
    }
    
    func merge(left []int, right []int) []int {
    	result := make([]int, 0, len(left) + len(right))
      
    	for len(left) > 0 && len(right) > 0 {
    		if left[0] < right[0] {
    			result = append(result, left[0])
    			left = left[1:]
    		} else {
    			result = append(result, right[0])
    			right = right[1:]
    		}
    	}
      
    	
    	result = append(result, left...)
    	result = append(result, right...)
      
    	return result
    }
    
    • package kata
    • func MergeSort(data []int) []int {
    • if len(data) <= 1 {
    • return data
    • }
    • mid := len(data) / 2
    • return merge(MergeSort(data[:mid]), MergeSort(data[mid:]))
    • }
    • func merge(left []int, right []int) []int {
    • result := make([]int, 0, len(left)+len(right))
    • result := make([]int, 0, len(left) + len(right))
    • for len(left) > 0 && len(right) > 0 {
    • if left[0] < right[0] {
    • result = append(result, left[0])
    • left = left[1:]
    • } else {
    • result = append(result, right[0])
    • right = right[1:]
    • }
    • }
    • if len(left) > 0 {
    • result = append(result, left...)
    • }
    • if len(right) > 0 {
    • result = append(result, right...)
    • }
    • result = append(result, left...)
    • result = append(result, right...)
    • return result
    • }