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.

I'm only using true and operands this time

Code
Diff
  • def returnhundred(s):
        return (True + True + True + True + True + True + True + True + True + True) ** (True + True)
        
  • 1
    def returnhundred(word):return 100
    
    1+
    def returnhundred(s):
    
    2+
        return (True + True + True + True + True + True + True + True + True + True) ** (True + True)
    
    22
        
    
Variables
Basic Language Features
Fundamentals
Conditional Statements
Control Flow
Loops
Arrays
Code
Diff
  • def is_prime(num):
        if not num&1 and num != 2:
            return False
        for i in range(3, int(num ** 0.5) + 1, 2):
            if not num % i:
                return False
        return True
    
    def get_primes(max_num):
        return [i for i in range(2, max_num) if is_prime(i)]
  • 1
    import math
    
    2
    33
    def is_prime(num):
    
    4
        if(not (num&1) and num != 2):
    
    2+
        if not num&1 and num != 2:
    
    55
            return False
    
    6
        for i in range(3, int(math.sqrt(num)) + 1, 2):
    
    7
            if (num % i) == 0:
    
    4+
        for i in range(3, int(num ** 0.5) + 1, 2):
    
    5+
            if not num % i:
    
    88
                return False
    
    99
        return True
    
    1010
    1111
    def get_primes(max_num):
    
    1212
        return [i for i in range(2, max_num) if is_prime(i)]
    

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
    
Code
Diff
  • decr = lambda a: sum(int(h, 16) for h in a.split(':'))
  • 1
    decr = lambda a: sum([int(h,16) for h in a.split(':')])
    
    1+
    decr = lambda a: sum(int(h, 16) for h in a.split(':'))
    
Fundamentals
Numbers
Mathematics
Algorithms
Code
Diff
  • def temperature_convert(temperature):
        value, a, b = temperature
    
        if a == b:
            return value
        
        converter = {'ck': value + 273.15,
                     'cr': (value * 1.8) + 491.67,
                     'cf': (value * 1.8) + 32,
                     'rc': (value - 491.67) * (5/9),
                     'rk': value * (5/9),
                     'rf': value - 459.67,
                     'kc': value - 273.15,
                     'kr': value * 1.8,
                     'kf': ((value - 273.15) * 1.8) + 32,
                     'fc': (value - 32) * (5/9),
                     'fk': ((value - 32) * (5/9)) + 273.15,
                     'fr': value + 459.67}
        
        return int(converter[str(a + b)])
  • 11
    def temperature_convert(temperature):
    
    2+
        value, a, b = temperature
    
    3+
    4+
        if a == b:
    
    5+
            return value
    
    22
        
    
    3
        if temperature[1] == temperature[2]:
    
    4
            return temperature[0]
    
    7+
        converter = {'ck': value + 273.15,
    
    8+
                     'cr': (value * 1.8) + 491.67,
    
    9+
                     'cf': (value * 1.8) + 32,
    
    10+
                     'rc': (value - 491.67) * (5/9),
    
    11+
                     'rk': value * (5/9),
    
    12+
                     'rf': value - 459.67,
    
    13+
                     'kc': value - 273.15,
    
    14+
                     'kr': value * 1.8,
    
    15+
                     'kf': ((value - 273.15) * 1.8) + 32,
    
    16+
                     'fc': (value - 32) * (5/9),
    
    17+
                     'fk': ((value - 32) * (5/9)) + 273.15,
    
    18+
                     'fr': value + 459.67}
    
    55
        
    
    6
        converter = {'ck': '{} + 273.15',
    
    7
                     'cr': '({} * 1.8) + 491.67',
    
    8
                     'cf': '({} * 1.8) + 32',
    
    9
                     'rc': '({} - 491.67) * (5/9)',
    
    10
                     'rk': '{} * (5/9)',
    
    11
                     'rf': '{} - 459.67',
    
    12
                     'kc': '{} - 273.15',
    
    13
                     'kr': '{} * 1.8',
    
    14
                     'kf': '(({} - 273.15) * 1.8) + 32',
    
    15
                     'fc': '({} - 32) * (5/9)',
    
    16
                     'fk': '(({} - 32) * (5/9)) + 273.15',
    
    17
                     'fr': '{} + 459.67'}
    
    18
        
    
    19
        value = temperature[0]
    
    20
        formula = converter[str(temperature[1] + temperature[2])]
    
    21
        
    
    22
        return int(eval(formula.format(value)))
    
    20+
        return int(converter[str(a + b)])