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.
def no_trespassing(func): def grass(lawn): res = func(lawn) if res is None: return 'No trespassing!' return func(lawn) return grass @no_trespassing def get_of_my_lawn(on_my_lawn): if on_my_lawn: return 'get of my lawn'
- def no_trespassing(func):
- def grass(lawn):
- res = func(lawn)
- if res is None:
- return 'No trespassing!'
- return func(lawn)
- return grass
- @no_trespassing
- def get_of_my_lawn(on_my_lawn):
- if on_my_lawn:
return "get of my lawn"- return 'get of my lawn'
import codewars_test as test from solution import get_of_my_lawn, no_trespassing @test.describe("Example") def test_group(): @test.it("test case 1: True ") def test_case(): lawn = True test.assert_equals(get_of_my_lawn(lawn), 'get of my lawn') @test.it("test case 2: False ") def test_case(): lawn = False test.assert_equals(get_of_my_lawn(lawn), 'No trespassing!')
- import codewars_test as test
# TODO Write testsimport solution # or from solution import example- from solution import get_of_my_lawn, no_trespassing
# test.assert_equals(actual, expected, [optional] message)- @test.describe("Example")
- def test_group():
@test.it("test case")- @test.it("test case 1: True ")
- def test_case():
test.assert_equals(1 + 1, 2)- lawn = True
- test.assert_equals(get_of_my_lawn(lawn), 'get of my lawn')
- @test.it("test case 2: False ")
- def test_case():
- lawn = False
- test.assert_equals(get_of_my_lawn(lawn), 'No trespassing!')
def fibonacci(n, cache={0:0, 1:1}): if n in cache: return cache[n] else: cache[n] = fibonacci(n - 1) + fibonacci(n - 2) return cache[n]
def fibonacci(n):if n in [0, 1]:return nelse:return fibonacci(n - 1) + fibonacci(n - 2)- def fibonacci(n, cache={0:0, 1:1}):
- if n in cache:
- return cache[n]
- else:
- cache[n] = fibonacci(n - 1) + fibonacci(n - 2)
- return cache[n]
import codewars_test as test from solution import fibonacci @test.describe("Example") def test_group(): @test.it("test case 1: Testing with cache memoization") def test_case(): test.assert_equals(fibonacci(0), 0) test.assert_equals(fibonacci(1), 1) test.assert_equals(fibonacci(7), 13) test.assert_equals(fibonacci(10), 55) test.assert_equals(fibonacci(20), 6765) test.assert_equals(fibonacci(25), 75025) test.assert_equals(fibonacci(35), 9227465) test.assert_equals(fibonacci(55), 139583862445) test.assert_equals(fibonacci(76), 3416454622906707) test.assert_equals(fibonacci(101), 573147844013817084101) test.assert_equals(fibonacci(237), 15156039800290547036315704478931467953361427680642) test.assert_equals(fibonacci(776), 668226711200301698374224176558256700160458774333255425461900331623619273605518323137569702870357755802337031006361339094239227806499153841600804020665750176206357)
- import codewars_test as test
- from solution import fibonacci
- @test.describe("Example")
- def test_group():
@test.it("test case")- @test.it("test case 1: Testing with cache memoization")
- def test_case():
- test.assert_equals(fibonacci(0), 0)
- test.assert_equals(fibonacci(1), 1)
- test.assert_equals(fibonacci(7), 13)
- test.assert_equals(fibonacci(10), 55)
- test.assert_equals(fibonacci(20), 6765)
- test.assert_equals(fibonacci(25), 75025)
# starts to lag....test.assert_equals(fibonacci(35), 9227465)- test.assert_equals(fibonacci(35), 9227465)
- test.assert_equals(fibonacci(55), 139583862445)
- test.assert_equals(fibonacci(76), 3416454622906707)
- test.assert_equals(fibonacci(101), 573147844013817084101)
- test.assert_equals(fibonacci(237), 15156039800290547036315704478931467953361427680642)
- test.assert_equals(fibonacci(776), 668226711200301698374224176558256700160458774333255425461900331623619273605518323137569702870357755802337031006361339094239227806499153841600804020665750176206357)
def dollars(pennies=0, nickles=0, dimes=0, quarters=0): return sum([pennies + (nickles * 5) + (dimes * 10) + (quarters * 25)]) / 100
def pennies(dollar):return 100*dollar- def dollars(pennies=0, nickles=0, dimes=0, quarters=0):
- return sum([pennies + (nickles * 5) + (dimes * 10) + (quarters * 25)]) / 100
import codewars_test as test from solution import dollars @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(dollars(pennies=1), .01) test.assert_equals(dollars(pennies=-1, quarters=1), .24) test.assert_equals(dollars(pennies=100, nickles=20, dimes=10, quarters=4), 4.0) test.assert_equals(dollars(pennies=11983, nickles=4656, dimes=18632, quarters=19878), 7185.33) test.assert_equals(dollars(pennies=87764765476, nickles=19724764665856, dimes=7589321418, quarters=2198191), 987875362637.11) test.assert_equals(dollars(pennies=-624765476, nickles=2476469, dimes=-3214318, quarters=852179192), 206599534.89)
- import codewars_test as test
# TODO Write testsimport solution # or from solution import example- from solution import dollars
# test.assert_equals(actual, expected, [optional] message)- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
test.assert_equals(1 + 1, 2)- test.assert_equals(dollars(pennies=1), .01)
- test.assert_equals(dollars(pennies=-1, quarters=1), .24)
- test.assert_equals(dollars(pennies=100, nickles=20, dimes=10, quarters=4), 4.0)
- test.assert_equals(dollars(pennies=11983, nickles=4656, dimes=18632, quarters=19878), 7185.33)
- test.assert_equals(dollars(pennies=87764765476, nickles=19724764665856, dimes=7589321418, quarters=2198191), 987875362637.11)
- test.assert_equals(dollars(pennies=-624765476, nickles=2476469, dimes=-3214318, quarters=852179192), 206599534.89)
def will_this_work(acc, x, y, z): for x in ((acc := acc, x), (y := z, 76), (acc, b := acc)): acc += 1 return acc + b
def will_this_work():acc=0for x in ((),(),()):acc+=1return acc- def will_this_work(acc, x, y, z):
- for x in ((acc := acc, x), (y := z, 76), (acc, b := acc)):
- acc += 1
- return acc + b
import codewars_test as test from solution import will_this_work import random @test.describe("Example") def test_group(): @test.it("test case") def test_case(): for n in range(100): a, x, y, z = [random.randint(100, 999) for i in range(4)] sample = will_this_work(a, x, y, z) shikataganai = lambda i: i * 2 + 3 test.assert_equals(sample, shikataganai(a))
- import codewars_test as test
# TODO Write testsimport solution # or from solution import example- from solution import will_this_work
- import random
# test.assert_equals(actual, expected, [optional] message)- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
test.assert_equals(1 + 1, 2)- for n in range(100):
- a, x, y, z = [random.randint(100, 999) for i in range(4)]
- sample = will_this_work(a, x, y, z)
- shikataganai = lambda i: i * 2 + 3
- test.assert_equals(sample, shikataganai(a))
import requests from bs4 import BeautifulSoup def random_quote() -> tuple: url = 'https://quotes.toscrape.com/random' response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') quote = soup.find('span', attrs={'class':'text'}).text author = soup.find('small', attrs={'class':'author'}).text return response.status_code, quote, author,
from random import randintquotes= ["Captain Teemo on duty.","Yes, sir!", "Armed and ready.","Reporting in.","Hut, two, three, four.","I'll scout ahead!","Swiftly!","That's gotta sting.","Never underestimate the power of the Scout's code.","Size doesn't mean everything."]def motivation():return quotes[randint(0,len(quotes)-1)]- import requests
- from bs4 import BeautifulSoup
- def random_quote() -> tuple:
- url = 'https://quotes.toscrape.com/random'
- response = requests.get(url)
- soup = BeautifulSoup(response.text, 'html.parser')
- quote = soup.find('span', attrs={'class':'text'}).text
- author = soup.find('small', attrs={'class':'author'}).text
- return response.status_code, quote, author,
import codewars_test as test from solution import random_quote @test.describe("Example") def test_group(): @test.it("test case 1: status code == 200") def test_case(): res = random_quote() sample = random_quote() test.assert_equals(sample[0], 200) @test.it("test case 2: test length of response") def test_case(): sample = random_quote() test.assert_equals(len(sample), 3)
- import codewars_test as test
# TODO Write testsimport solution # or from solution import exampleprint(motivation())# test.assert_equals(actual, expected, [optional] message)- from solution import random_quote
- @test.describe("Example")
- def test_group():
@test.it("test case")- @test.it("test case 1: status code == 200")
- def test_case():
test.assert_equals(1 + 1, 2)- res = random_quote()
- sample = random_quote()
- test.assert_equals(sample[0], 200)
- @test.it("test case 2: test length of response")
- def test_case():
- sample = random_quote()
- test.assert_equals(len(sample), 3)