Begin a new Kumite
Search
About
  • Filter by Language:
  • 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.

Code
Diff
  • def returnhundred(*_):
        return True*10**2
        
  • 1
    def returnhundred(s):
    
    2
        return (True + True + True + True + True + True + True + True + True + True) ** (True + True)
    
    1+
    def returnhundred(*_):
    
    2+
        return True*10**2
    
    33
        
    

Recent Moves:

Code
Diff
  • switchout = str.replace
  • 1
    def switchout(sentence, word, switch):
    
    2
        return sentence.replace(word, switch)
    
    1+
    switchout = str.replace
    

Recent Moves:

Variables
Basic Language Features
Fundamentals
Conditional Statements
Control Flow
Loops
Arrays
Code
Diff
  • from math import ceil
    
    #same sieve of erasthosthenes...
    #starting with odd values, using lesser memory
    
    def get_primes(n):
        length = (n+1) // 2
        p = [1] * length
        p[0] = 0
        sqrti = ceil(((n+1)**.5 - 1) / 2)
        for i in range(1, sqrti):
            if p[i]:
                x = 2*i+1
                start = (x**2-1)//2
                p[start::x] = [0] * ceil((length - start) / x)            
        return [2] + [i*2+1 for i, v in enumerate(p) if v]
    
  • 1
    def get_primes(n):    
    
    2
        bpr = [0,1] * ((n+1)//2) + [0] * (1 - (1 * 1&n))
    
    3
        bpr[:3] = [0, 0, 1]
    
    4
        for i in range(3, 1+ int(n**0.5), 2):
    
    5
            if bpr[i]:
    
    6
                ipi, isq = i*2, i*i
    
    7
                bpr[isq::ipi] = [0] * (( n - isq)//ipi + 1)
    
    8
        return [2] + [i for i in range(3,n,2) if bpr[i]]
    
    1+
    from math import ceil
    
    2+
    3+
    #same sieve of erasthosthenes...
    
    4+
    #starting with odd values, using lesser memory
    
    5+
    6+
    def get_primes(n):
    
    7+
        length = (n+1) // 2
    
    8+
        p = [1] * length
    
    9+
        p[0] = 0
    
    10+
        sqrti = ceil(((n+1)**.5 - 1) / 2)
    
    11+
        for i in range(1, sqrti):
    
    12+
            if p[i]:
    
    13+
                x = 2*i+1
    
    14+
                start = (x**2-1)//2
    
    15+
                p[start::x] = [0] * ceil((length - start) / x)            
    
    16+
        return [2] + [i*2+1 for i, v in enumerate(p) if v]
    

Recent Moves:

Algorithms

A quick sort algorithm.

from copy import deepcopy

def partition(l,deb,fin):
    p=deb
    pivot=l[deb]
    for k in range(deb+1,fin):
        if l[k]<pivot:
            p+=1
            l[p],l[k]=l[k],l[p]
    l[p],l[deb]=l[deb],l[p]
    return p

def Tri_Rapide(ll):
    l = deepcopy(ll)
    def tri(deb,fin):
        if deb<fin:
            p=partition(l,deb,fin)
            tri(deb,p)
            tri(p+1,fin)
    tri(0,len(l))
    return l

Hello My Wars

function test() {

}
Code
Diff
  • import random
    
    def rubegoldberg():
        find = "codewars"
        total = 1 - len(find)
    
        for x, y in enumerate(find):
            if x % 2:
                total -= ord(y) - 97
            else:
                total += ord(y) - 97        
    
        for n in random.sample([i for i in range(10)], 10):
            if n:
                a = 1 / n
            else:
                return total
  • 1
    import string
    
    22
    import random
    
    33
    44
    def rubegoldberg():
    
    5
        alpha = string.ascii_lowercase
    
    6
        find, total = "codewars", 1
    
    4+
        find = "codewars"
    
    5+
        total = 1 - len(find)
    
    6+
    77
        for x, y in enumerate(find):
    
    8
            if x % 2 == 0:
    
    9
                total += alpha.index(y)
    
    8+
            if x % 2:
    
    9+
                total -= ord(y) - 97
    
    1010
            else:
    
    11
                total -= alpha.index(y)
    
    12
        total -= len(find)
    
    13
        nums = []
    
    14
        for i in range(0, 10):
    
    15
            nums.append(i)
    
    16
        random.shuffle(nums)
    
    17
        try:
    
    18
            for n in nums:
    
    11+
                total += ord(y) - 97        
    
    12+
    13+
        for n in random.sample([i for i in range(10)], 10):
    
    14+
            if n:
    
    1919
                a = 1 / n
    
    20
        except ZeroDivisionError:
    
    21
            return total
    
    16+
            else:
    
    17+
                return total