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
  • import math
    import numpy as np
    g = 9.81
    def calc_time_of_impact(speed, angle, origin_y):
        angle = np.deg2rad(angle)
        if origin_y:
            return (speed * math.sin(angle) + math.sqrt((speed * math.sin(angle))**2 + 2 * g * origin_y)) / g
        return 2 * speed * math.sin(angle) / g 
    • import math
    • import numpy as np
    • g = 9.81
    • def calc_time_of_impact(speed, angle, origin_y):
    • angle = np.deg2rad(angle)
    • if origin_y:
    • return (speed * math.sin(angle) + math.sqrt((speed * math.sin(angle))**2 + 2 * g * origin_y)) / g
    • return 2 * speed * math.sin(angle) / g
Code
Diff
  • import math
    def CirclePoint(angle):
        #y = math.sin(angle)
        #usx = math.sqrt(-y**2 + 1)
        #return (-usx if math.pi * 0.5 < angle < math.pi * 1.5 else usx, y)
    
        y = angle - (angle**3)/math.factorial(3) \
        + (angle**5)/math.factorial(5) \
        - (angle**7)/math.factorial(7)
        x = angle - (angle**2)/math.factorial(2) \
        + (angle**4)/math.factorial(4) \
        - (angle**6)/math.factorial(6) 
        print(y)
        print(x)
        return (x,y)
    • import math
    • def CirclePoint(angle):
    • #y = math.sin(angle)
    • #usx = math.sqrt(-y**2 + 1)
    • #return (-usx if math.pi * 0.5 < angle < math.pi * 1.5 else usx, y)
    • y = angle - (angle**3)/math.factorial(3) \
    • + (angle**5)/math.factorial(5) \
    • - (angle**7)/math.factorial(7)
    • x = angle - (angle**2)/math.factorial(2) \
    • + (angle**4)/math.factorial(4) \
    • - (angle**6)/math.factorial(6)
    • print(y)
    • print(x)
    • return (x,y)
Code
Diff
  • from operator import itemgetter
    from operator import getitem
    from operator import setitem
    from sys import stdout
    from sys import argv
    
    def kata(sin):
        def _():
            while itemgetter(ptr)(tape):
                yield
        def idxs(option):
            if type(option) == dict:
                for x in option:
                    yield x
                    yield from idxs(itemgetter(x)(option))
            else:
                yield option
        def ulip(guard):
            assert not guard
            return lambda arbitrary: arbitrary
        tape = 30000 * list(range(1))
        ptr = 0
        sinptr = ~0
    
        print(ptr)
        (ptr := ulip(ptr >= 29999)(abs(~ptr))) and False
        print(ptr)
        (ptr := ulip(ptr <= 0)(len(range(*idxs({1: ptr}))))) and False
        print(ptr)
        setitem(*reversed(tuple(idxs(
            {ord(getitem(sin, sinptr := abs(~sinptr))): {ptr: tape}}))))
        setitem(*reversed(tuple(idxs(
            {itemgetter(ptr)(tape) + 1 & 0xff: {ptr: tape}}))))
        [setitem(*reversed(tuple(idxs(
            {itemgetter(ptr)(tape) - 1 & 0xff: {ptr: tape}}))))
        or stdout.write(chr(itemgetter(ptr)(tape))) and False
        or setitem(*reversed(tuple(idxs(
            {ord(getitem(sin, sinptr := abs(~sinptr))): {ptr: tape}}))))
        or setitem(*reversed(tuple(idxs(
            {itemgetter(ptr)(tape) + 1 & 0xff: {ptr: tape}}))))
        for _0 in _()]
    
    if __name__ == "__main__":
        # pretty much stdin, right? right??
        kata(itemgetter(1)(argv))
    
    
    • # no cheating methods such as eval exec
    • # has the same relevant chars (nothing hidden in comment)
    • #from __future__ import braces # 深紅心 wishes you'd at least consider it
    • from operator import itemgetter
    • from operator import getitem
    • from operator import setitem
    • from sys import stdout
    • from sys import argv
    • def kata(sin):
    • def _():
    • while itemgetter(ptr)(tape):
    • yield
    • def idxs(option):
    • if type(option) == dict:
    • for x in option:
    • yield x
    • yield from idxs(itemgetter(x)(option))
    • else:
    • yield option
    • def ulip(guard):
    • assert not guard
    • return lambda arbitrary: arbitrary
    • tape = 30000 * list(range(1))
    • ptr = 0
    • sinptr = ~0
    • print(ptr)
    • (ptr := ulip(ptr >= 29999)(abs(~ptr))) and False
    • print(ptr)
    • (ptr := ulip(ptr <= 0)(len(range(*idxs({1: ptr}))))) and False
    • print(ptr)
    • setitem(*reversed(tuple(idxs(
    • {ord(getitem(sin, sinptr := abs(~sinptr))): {ptr: tape}}))))
    • setitem(*reversed(tuple(idxs(
    • {itemgetter(ptr)(tape) + 1 & 0xff: {ptr: tape}}))))
    • [setitem(*reversed(tuple(idxs(
    • {itemgetter(ptr)(tape) - 1 & 0xff: {ptr: tape}}))))
    • or stdout.write(chr(itemgetter(ptr)(tape))) and False
    • or setitem(*reversed(tuple(idxs(
    • {ord(getitem(sin, sinptr := abs(~sinptr))): {ptr: tape}}))))
    • or setitem(*reversed(tuple(idxs(
    • {itemgetter(ptr)(tape) + 1 & 0xff: {ptr: tape}}))))
    • for _0 in _()]
    • if __name__ == "__main__":
    • # pretty much stdin, right? right??
    • kata(itemgetter(1)(argv))
Code
Diff
  • f,h=lambda r,n:[int(h(r,n-1).rjust(r,"1")),-1][r**r<n],lambda r,n:h(r,n//r)+str(n%r+1)if n else""
    • """
    • f,h=lambda r,n:r**r<n and-1or int(h(r,n-1).rjust(r,"1")),lambda r,n:h(r,n//r)+str(n%r+1)if n else""
    • """
    • f,h=lambda r,n:[int(h(r,n-1).rjust(r,"1")),-1][r**r<n],lambda r,n:h(r,n//r)+str(n%r+1)if n else""
Mathematics
Algorithms
Logic
Numbers
Data Types
Code
Diff
  • def is_happy(x, *, _trie=[False,10*[False]+[[True]]]+8*[False]+[[False]]):
        a = [False]
        while True:
            z = 0
            t = _trie
            while x:
                r = x%10
                x //= 10
                z += r*r
                if t[r]:
                    t = t[r]
                else:
                    t[r] = (11-(not r))*[False]
                    t = t[r]
                    while x:
                        r = x%10
                        x //= 10
                        z += r*r
                        t[r] = (11-(not r))*[False]
                        t = t[r]
                    break
            else:
                if t[10]:
                    a[0] = t[10][0]
                    return a[0]
            t[10] = a
            x = z
    • def is_happy(x, *, _trie=[False,10*[False]+[[True]]]+8*[False]+[[False]]):
    • a = [False]
    • while True:
    • z = 0 # wasting some operations when x is in _trie. nobody cares though.
    • z = 0
    • t = _trie
    • while x:
    • r = x%10
    • x //= 10
    • z += r*r
    • if t[r]:
    • t = t[r]
    • else:
    • t[r] = (11-(not r))*[False]
    • t = t[r]
    • while x:
    • r = x%10
    • x //= 10
    • z += r*r
    • t[r] = (11-(not r))*[False]
    • t = t[r]
    • break
    • else:
    • if t[10]:
    • a[0] = t[10][0]
    • return a[0]
    • t[10] = a
Code
Diff
  • def purple():
        return 'purple'
    def red():
        raise ZeroDivisionError()
    def blue():
        return (1/3) * 3
    • def purple():
    • return 'purple'
    • def red():
    • raise ZeroDivisionError()
    • def blue():
    • return (1/3) * 3
Lists
Data Structures
Code
Diff
  • def generate_binary_list(a, b, c, d):
        (a, b)= (a, b, a)[d&1:][:2]
        return [*((a, b)*(c-d>>1)), *(a,)[:c>d][:c-d&1]]
    • def generate_binary_list(a, b, c, d):
    • (a, b) = (a, b, a)[d&1:][:2]
    • (a, b)= (a, b, a)[d&1:][:2]
    • return [*((a, b)*(c-d>>1)), *(a,)[:c>d][:c-d&1]]
Code
Diff
  • find_multiples= lambda b, l:[x for x in range(b,l+1,b)]
    • find_multiples = lambda b, l:[x for x in range(b,l+1,b)]
    • find_multiples= lambda b, l:[x for x in range(b,l+1,b)]
Code
Diff
  • def optimal_gifts(gifts: int, recipients: int) -> int:
        if recipients > gifts or gifts == 4 and recipients == 1:
            return None
        if gifts >= recipients * 8:
            return recipients
        if gifts == recipients * 8 - 4 or gifts == (recipients - 1) * 8:
            return recipients - 2
        return gifts// 8
    • def optimal_gifts(gifts: int, recipients: int) -> int:
    • if recipients > gifts or gifts == 4 and recipients == 1:
    • return None
    • if gifts >= recipients * 8:
    • return recipients
    • if gifts == recipients * 8 - 4 or gifts == (recipients - 1) * 8:
    • return recipients - 2
    • return gifts // 8
    • return gifts// 8
Code
Diff
  • add= lambda *x: sum(x)
    • add = lambda *x: sum(x)
    • add= lambda *x: sum(x)