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 where_were_you_when_codewars_died(activity='codewarz', location='127.0.0.1', food_source='coffee'): db = Connection() record = f"I was at {location} consuming {food_source} when {activity} died." return db.add_record(record)
where = lambda thing="codewar",home="home",food="dorito",phone="phone" : f"where were u wen {thing} die?\ni was at {home} eatin {food} wen {phone} ring\n\"{thing} is kil\"\n\"no\""- def where_were_you_when_codewars_died(activity='codewarz', location='127.0.0.1', food_source='coffee'):
- db = Connection()
- record = f"I was at {location} consuming {food_source} when {activity} died."
- return db.add_record(record)
import codewars_test as test from solution import Connection, where_were_you_when_codewars_died # test.assert_equals(actual, expected, [optional] message) @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(where_were_you_when_codewars_died(activity='codewars', location='127.0.0.1', food_source='coffee'), 'I was at 127.0.0.1 consuming coffee when codewars died.')
- import codewars_test as test
# TODO Write testsimport solution # or from solution import exampleprint(where())print(where("Club penguin",home="house",food="dorito"))- from solution import Connection, where_were_you_when_codewars_died
- # 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)- def test_case():
- test.assert_equals(where_were_you_when_codewars_died(activity='codewars', location='127.0.0.1', food_source='coffee'), 'I was at 127.0.0.1 consuming coffee when codewars died.')
def flatten_list(lst): def flatten(l): for i in l: if isinstance(i, (list, tuple)): for j in flatten_list(i): yield j else: yield i return list(flatten(lst))
- def flatten_list(lst):
pass- def flatten(l):
- for i in l:
- if isinstance(i, (list, tuple)):
- for j in flatten_list(i):
- yield j
- else:
- yield i
- return list(flatten(lst))
import codewars_test as test from solution import flatten_list @test.describe("Fixd tests") def test_group(): @test.it("test case 1:") def test_case(): s1 = [[0, 1, 2], [3, 4], [5, 6], [7, 8], [9]] s2 = [[0, 1, 2, 3, 4], [5, 6, 7, 8], [9]] s3 = [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9]] e1 = [0, 1, 2, 3, 4, 5, 6, 7,8, 9] e2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] e3 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] samples = [s1, s2, s3] expected = [e1, e2, e3] for s, e in zip(samples, expected): test.assert_equals(flatten_list(s),e) @test.describe("Random tests") def test_group(): @test.it("test case 2:") def test_case(): s1 = [[0, 1, 2], (3, 4), [5, 6], (7, 8), [9]] s2 = [[0, 1, 2, 3, 4], [5, 6, 7, 8], (9)] s3 = [(0), [1], (2), [3], (4), [5], (6), [7], (8), [9]] e1 = [0, 1, 2, 3, 4, 5, 6, 7,8, 9] e2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] e3 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] samples = [s1, s2, s3] expected = [e1, e2, e3] for s, e in zip(samples, expected): test.assert_equals(flatten_list(s),e) def test_group(): @test.it("test case 1:") def test_case(): s1 = [0, [1, 2], 3, [4, 5], 6, [7, 8], 9] s2 = [0, 1, 2, [3, 4, 5], 6, 7, 8, [9]] s3 = [0, [1], 2, [3], 4, [5], 6, [7], 8, [9]] s4 = [0, 1, 2, [3, 4, [5], []], [6], 7, 8, [9,[]]] e1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] e2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] e3 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] e4 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] samples = [s1, s2, s3, s4] expected = [e1, e2, e3, e4] for s, e in zip(samples, expected): test.assert_equals(flatten_list(s),e) @test.it("test case 2:") def test_case(): s1 = [[[[[[[[-1]]]]]]]] s2 = [1, 2, [3, 4, [5], ['code']], [6, [[[7, 'warz']]], 8, [[[9,[]]]]]] s3 = ['code', [[[[1, 2, 3], 4], 5]], 6, 7, [[], 8], [9, [[], 'warz']]] e1 = [-1] e2 = [1, 2, 3, 4, 5, 'code', 6, 7, 'warz',8, 9 ] e3 = ['code', 1, 2, 3, 4, 5, 6, 7, 8, 9, 'warz'] samples = [s1,s2, s3] expected = [e1, e2, e3] for s, e in zip(samples, expected): test.assert_equals(flatten_list(s),e) @test.describe("Edge Cases") def test_group(): @test.it("test case 1:") def test_case(): s1 = [0, 1, (2, 3), [[4, 5, (6, 7, (8,), [9]), 10]], (11,)] s2 = [0, [[[1]]], ([2, 3], [4, [[5, 6]]])] s3 = [1, [3], (1, 6), [[3, 8]], [[[5]]], 9, ((((2,),),),)] s4 = ['eat', (0, ([1, 2, [3, [['sleep', [[4]]]]], (((6,),),), 'code', 7, [[[8]]], 9]),), 'repeat'] e1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] e2 = [0, 1, 2, 3, 4, 5, 6] e3 = [1, 3, 1, 6, 3, 8, 5, 9, 2] e4 = ['eat', 0, 1, 2, 3, 'sleep', 4, 6, 'code', 7, 8, 9, 'repeat'] samples = [s1, s2, s3, s4] expected = [e1, e2, e3, e4] for s, e in zip(samples, expected): test.assert_equals(flatten_list(s),e)
- import codewars_test as test
- from solution import flatten_list
- @test.describe("Fixd tests")
- def test_group():
- @test.it("test case 1:")
- def test_case():
- s1 = [[0, 1, 2], [3, 4], [5, 6], [7, 8], [9]]
- s2 = [[0, 1, 2, 3, 4], [5, 6, 7, 8], [9]]
- s3 = [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9]]
- e1 = [0, 1, 2, 3, 4, 5, 6, 7,8, 9]
- e2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
- e3 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
- samples = [s1, s2, s3]
- expected = [e1, e2, e3]
- for s, e in zip(samples, expected):
- test.assert_equals(flatten_list(s),e)
- @test.describe("Random tests")
- def test_group():
- @test.it("test case 2:")
- def test_case():
- s1 = [[0, 1, 2], (3, 4), [5, 6], (7, 8), [9]]
- s2 = [[0, 1, 2, 3, 4], [5, 6, 7, 8], (9)]
- s3 = [(0), [1], (2), [3], (4), [5], (6), [7], (8), [9]]
- e1 = [0, 1, 2, 3, 4, 5, 6, 7,8, 9]
- e2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
- e3 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
- samples = [s1, s2, s3]
- expected = [e1, e2, e3]
- for s, e in zip(samples, expected):
- test.assert_equals(flatten_list(s),e)
@test.describe("Random tests")- def test_group():
- @test.it("test case 1:")
- def test_case():
- s1 = [0, [1, 2], 3, [4, 5], 6, [7, 8], 9]
- s2 = [0, 1, 2, [3, 4, 5], 6, 7, 8, [9]]
- s3 = [0, [1], 2, [3], 4, [5], 6, [7], 8, [9]]
- s4 = [0, 1, 2, [3, 4, [5], []], [6], 7, 8, [9,[]]]
- e1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
- e2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
- e3 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
- e4 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
- samples = [s1, s2, s3, s4]
- expected = [e1, e2, e3, e4]
- for s, e in zip(samples, expected):
- test.assert_equals(flatten_list(s),e)
- @test.it("test case 2:")
- def test_case():
- s1 = [[[[[[[[-1]]]]]]]]
- s2 = [1, 2, [3, 4, [5], ['code']], [6, [[[7, 'warz']]], 8, [[[9,[]]]]]]
- s3 = ['code', [[[[1, 2, 3], 4], 5]], 6, 7, [[], 8], [9, [[], 'warz']]]
- e1 = [-1]
- e2 = [1, 2, 3, 4, 5, 'code', 6, 7, 'warz',8, 9 ]
- e3 = ['code', 1, 2, 3, 4, 5, 6, 7, 8, 9, 'warz']
- samples = [s1,s2, s3]
- expected = [e1, e2, e3]
- for s, e in zip(samples, expected):
- test.assert_equals(flatten_list(s),e)
- @test.describe("Edge Cases")
- def test_group():
- @test.it("test case 1:")
- def test_case():
- s1 = [0, 1, (2, 3), [[4, 5, (6, 7, (8,), [9]), 10]], (11,)]
- s2 = [0, [[[1]]], ([2, 3], [4, [[5, 6]]])]
- s3 = [1, [3], (1, 6), [[3, 8]], [[[5]]], 9, ((((2,),),),)]
- s4 = ['eat', (0, ([1, 2, [3, [['sleep', [[4]]]]], (((6,),),), 'code', 7, [[[8]]], 9]),), 'repeat']
- e1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
- e2 = [0, 1, 2, 3, 4, 5, 6]
- e3 = [1, 3, 1, 6, 3, 8, 5, 9, 2]
- e4 = ['eat', 0, 1, 2, 3, 'sleep', 4, 6, 'code', 7, 8, 9, 'repeat']
- samples = [s1, s2, s3, s4]
- expected = [e1, e2, e3, e4]
- for s, e in zip(samples, expected):
- test.assert_equals(flatten_list(s),e)