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.
Previous thing, but lambda
test cases
import codewars_test as test from solution import Greeting import random def get_greeting(name, rank=None, formal=False): print(f'Hello,{" " + rank if rank is not None else ""} {name}.' if formal else f'Hey, {name}!') return f'Hello,{" " + rank if rank is not None else ""} {name}.' if formal else f'Hey, {name}!' names = [ 'Lisa', 'Skylar', 'Dylan', 'Harper', 'Susan', 'Kenneth', 'Quinn', 'Kevin', 'Morgan', 'Jordan', 'Finley', 'Karen', 'Michael', 'Emerson', 'Daniel', 'Avery', 'William', 'Michelle', 'Justice', 'David', 'Donald', 'Richard', 'Jennifer', 'Robert', 'Payton', 'John', 'James', 'Ariel', 'Skyler', 'Dorothy', 'Charles', 'Paul', 'Drew', 'Rory', 'Steven', 'Riley', 'Reese', 'Robin', 'Cameron', 'Mark', 'Jamie', 'Sarah', 'Jessica', 'Nancy', 'Anthony', 'Brian', 'Sandra', 'George', 'Helen', 'Melissa', 'Dakota', 'Mary', 'Alexis', 'Peyton', 'Alex', 'Charlie', 'Matthew', 'Patricia', 'Christopher', 'Edward', 'Elizabeth', 'Amanda', 'Sawyer', 'Margaret', 'Donna', 'Emily', 'Thomas', 'Bailey', 'Hayden', 'Rowan', 'Harley', 'Kai', 'Carol', 'Laura', 'Linda', 'Casey', 'Parker', 'Andrew', 'Joseph', 'Reagan', 'Emery', 'Phoenix', 'Taylor', 'Betty' ] titles = [ 'Duchess', 'Ambassador', 'Mistress', 'Executive', 'Sultan', 'Pharaoh', 'Baron', 'Mayor', 'Magistrate', 'Sergeant', 'Doctor', 'Sir', 'Lord', 'Vice President', 'Baroness', 'Cardinal', 'Officer', 'Archbishop', 'Duke', 'Agent', 'Madam', 'Queen', 'Minister', 'King', 'Captain', 'Pope', 'Master', 'Admiral', 'Princess', 'Lieutenant', 'Director', 'President', 'Governor', 'Commander', 'Prince', 'Detective', 'Professor', 'Sheikh', 'Bishop', 'Chancellor', 'Countess', 'Empress', 'Chief', 'Senator', 'Counselor', 'Emperor', 'Judge', 'General', 'Count' ] @test.describe("Fixed Tests") def test_group(): @test.it("Tests") def test_case(): test.assert_equals(Greeting('John'), 'Hey, John!') test.assert_equals(Greeting('Churchill', 'Sir', True), 'Hello, Sir Churchill.') test.assert_equals(Greeting('Einstein', 'Proffessor', False), 'Hey, Einstein!') test.assert_equals(Greeting('Jane', formal=True), 'Hello, Jane.') @test.describe("Random Tests") def random(): for test_number in range(100): qname = names[random.randint(0,len(names)-1)] qrank = titles[random.randint(0,len(titles)-1)] if random.randint(0,1)==1 else '' f = bool(random.randint(0,1)==0) @test.it(f'Random Test #{str(test_number+1)}: {qname}{", rank="+qrank if not qrank=="" else ""}, formal={f}') def _(): expected = f'Hello,{" "if not qrank=="" else ""}{qrank} {qname}.' if f else f'Hey, {qname}!' print(f'Expected Answer: "{expected}". Your Answer: "{Greeting(qname, qrank, f)}"') test.assert_equals(Greeting(qname, qrank, f), expected)
- import codewars_test as test
- from solution import Greeting
- import random
# Working solution / random generator- def get_greeting(name, rank=None, formal=False):
- print(f'Hello,{" " + rank if rank is not None else ""} {name}.' if formal else f'Hey, {name}!')
- return f'Hello,{" " + rank if rank is not None else ""} {name}.' if formal else f'Hey, {name}!'
def get_person():names = [- names = [
- 'Lisa', 'Skylar', 'Dylan', 'Harper', 'Susan', 'Kenneth', 'Quinn', 'Kevin', 'Morgan', 'Jordan', 'Finley',
- 'Karen', 'Michael', 'Emerson', 'Daniel', 'Avery', 'William', 'Michelle', 'Justice', 'David', 'Donald',
- 'Richard', 'Jennifer', 'Robert', 'Payton', 'John', 'James', 'Ariel', 'Skyler', 'Dorothy', 'Charles', 'Paul',
- 'Drew', 'Rory', 'Steven', 'Riley', 'Reese', 'Robin', 'Cameron', 'Mark', 'Jamie', 'Sarah', 'Jessica', 'Nancy',
- 'Anthony', 'Brian', 'Sandra', 'George', 'Helen', 'Melissa', 'Dakota', 'Mary', 'Alexis', 'Peyton', 'Alex',
- 'Charlie', 'Matthew', 'Patricia', 'Christopher', 'Edward', 'Elizabeth', 'Amanda', 'Sawyer', 'Margaret',
- 'Donna', 'Emily', 'Thomas', 'Bailey', 'Hayden', 'Rowan', 'Harley', 'Kai', 'Carol', 'Laura', 'Linda', 'Casey',
- 'Parker', 'Andrew', 'Joseph', 'Reagan', 'Emery', 'Phoenix', 'Taylor', 'Betty'
- ]
titles = [- titles = [
- 'Duchess', 'Ambassador', 'Mistress', 'Executive', 'Sultan', 'Pharaoh', 'Baron', 'Mayor', 'Magistrate',
- 'Sergeant', 'Doctor', 'Sir', 'Lord', 'Vice President', 'Baroness', 'Cardinal', 'Officer', 'Archbishop',
- 'Duke', 'Agent', 'Madam', 'Queen', 'Minister', 'King', 'Captain', 'Pope', 'Master', 'Admiral', 'Princess',
- 'Lieutenant', 'Director', 'President', 'Governor', 'Commander', 'Prince', 'Detective', 'Professor',
- 'Sheikh', 'Bishop', 'Chancellor', 'Countess', 'Empress', 'Chief', 'Senator', 'Counselor', 'Emperor', 'Judge',
- 'General', 'Count'
- ]
rand_num = random.randrange(1, 4)if rand_num == 1:return random.choice(names)if rand_num == 2:rand_name = random.choice(names)title_or_formal = random.choice([(random.choice(titles)), (random.randrange(1, 10) % 2 == 0)])return rand_name, title_or_formalrand_name = random.choice(names)rand_title = random.choice(titles)form = random.randrange(1, 10) % 2 == 0return rand_name, rand_title, form# START OF TESTING@test.describe("Example")- @test.describe("Fixed Tests")
- def test_group():
@test.it("Test case")- @test.it("Tests")
- def test_case():
# Corrected function calls- test.assert_equals(Greeting('John'), 'Hey, John!')
- test.assert_equals(Greeting('Churchill', 'Sir', True), 'Hello, Sir Churchill.')
- test.assert_equals(Greeting('Einstein', 'Proffessor', False), 'Hey, Einstein!')
- test.assert_equals(Greeting('Jane', formal=True), 'Hello, Jane.')
- @test.describe("Random Tests")
def random_stuff():for _ in range(100):person = get_person()@test.it(f"Testing: {person}")def test_random():if isinstance(person, tuple):if len(person) == 2:if isinstance(person[1], str):test.assert_equals(Greeting(person[0], rank=person[1]), get_greeting(person[0], rank=person[1]))else:test.assert_equals(Greeting(person[0], formal=person[1]), get_greeting(person[0], formal=person[1]))else:test.assert_equals(Greeting(*person), get_greeting(*person))else:test.assert_equals(Greeting(person), f'Hey, {person}!')- def random():
- for test_number in range(100):
- qname = names[random.randint(0,len(names)-1)]
- qrank = titles[random.randint(0,len(titles)-1)] if random.randint(0,1)==1 else ''
- f = bool(random.randint(0,1)==0)
- @test.it(f'Random Test #{str(test_number+1)}: {qname}{", rank="+qrank if not qrank=="" else ""}, formal={f}')
- def _():
- expected = f'Hello,{" "if not qrank=="" else ""}{qrank} {qname}.' if f else f'Hey, {qname}!'
- print(f'Expected Answer: "{expected}". Your Answer: "{Greeting(qname, qrank, f)}"')
- test.assert_equals(Greeting(qname, qrank, f), expected)