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.
The Goose is an experienced motorcyclist and pursuit officer of the MFP. When he is present (i.e. True
), The Interceptors speed increases by 20%.
import datetime def fury_road(interceptor, night_rider, motorcycle_gang, the_goose): def calc_time(d, s): time = d / s hours = int(time) minutes = int((time * 60) % 60) seconds = int((time * 3600) % 60) return datetime.time(hours, minutes, seconds) night_rider_time = calc_time(night_rider.distance, night_rider.speed) if motorcycle_gang: interceptor.speed -= (.20 * interceptor.speed) if the_goose: interceptor.speed += (.20 * interceptor.speed) interceptor_time = calc_time(interceptor.distance, interceptor.distance) else: interceptor_time = calc_time(interceptor.distance, interceptor.speed) if interceptor_time <= night_rider_time: return 'The Nightrider, remember his name when you look into the night sky...' else: return "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!"
- import datetime
def fury_road(interceptor, night_rider, motorcycle_gang):- def fury_road(interceptor, night_rider, motorcycle_gang, the_goose):
- def calc_time(d, s):
- time = d / s
- hours = int(time)
- minutes = int((time * 60) % 60)
- seconds = int((time * 3600) % 60)
- return datetime.time(hours, minutes, seconds)
- night_rider_time = calc_time(night_rider.distance, night_rider.speed)
- if motorcycle_gang:
- interceptor.speed -= (.20 * interceptor.speed)
- if the_goose:
- interceptor.speed += (.20 * interceptor.speed)
- interceptor_time = calc_time(interceptor.distance, interceptor.distance)
- else:
- interceptor_time = calc_time(interceptor.distance, interceptor.speed)
- if interceptor_time <= night_rider_time:
- return 'The Nightrider, remember his name when you look into the night sky...'
- else:
- return "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!"
import codewars_test as test from solution import fury_road, PersuitVehicle, Interceptor @test.describe("Example") def test_group(): @test.it("test case 1: Interceptor captures the Nightrider") def test_case(): test.assert_equals(fury_road(Interceptor(100, 150), PersuitVehicle(100, 150), False, False), 'The Nightrider, remember his name when you look into the night sky...') test.assert_equals(fury_road(Interceptor(75, 125), PersuitVehicle(50, 65), False, False), 'The Nightrider, remember his name when you look into the night sky...') test.assert_equals(fury_road(Interceptor(85, 130), PersuitVehicle(60, 55), True, True), 'The Nightrider, remember his name when you look into the night sky...') test.assert_equals(fury_road(Interceptor(120, 175), PersuitVehicle(100, 85), True, True), 'The Nightrider, remember his name when you look into the night sky...') @test.it("test case 2: The Nightrider evades capture") def test_case(): test.assert_equals(fury_road(Interceptor(100, 150), PersuitVehicle(100, 150), True, False), "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!") test.assert_equals(fury_road(Interceptor(121, 40), PersuitVehicle(120, 150), False, True), "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!") test.assert_equals(fury_road(Interceptor(155, 85), PersuitVehicle(5, 15), False, True), "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!") test.assert_equals(fury_road(Interceptor(185, 230), PersuitVehicle(5, 10), True, False), "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!") test.assert_equals(fury_road(Interceptor(100, 150), PersuitVehicle(100, 150), True, False), "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!") @test.it("test case 3: Goose assist!") def test_case(): test.assert_equals(fury_road(Interceptor(100, 150), PersuitVehicle(100, 150), False, True), "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!") test.assert_equals(fury_road(Interceptor(100, 150), PersuitVehicle(100, 150), True, True), "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!")
- import codewars_test as test
- from solution import fury_road, PersuitVehicle, Interceptor
- @test.describe("Example")
- def test_group():
- @test.it("test case 1: Interceptor captures the Nightrider")
- def test_case():
test.assert_equals(fury_road(Interceptor(100, 150), PersuitVehicle(100, 150), False), 'The Nightrider, remember his name when you look into the night sky...')test.assert_equals(fury_road(Interceptor(75, 125), PersuitVehicle(50, 65), False), 'The Nightrider, remember his name when you look into the night sky...')test.assert_equals(fury_road(Interceptor(85, 130), PersuitVehicle(60, 55), True), 'The Nightrider, remember his name when you look into the night sky...')test.assert_equals(fury_road(Interceptor(120, 175), PersuitVehicle(100, 85), True), 'The Nightrider, remember his name when you look into the night sky...')- test.assert_equals(fury_road(Interceptor(100, 150), PersuitVehicle(100, 150), False, False), 'The Nightrider, remember his name when you look into the night sky...')
- test.assert_equals(fury_road(Interceptor(75, 125), PersuitVehicle(50, 65), False, False), 'The Nightrider, remember his name when you look into the night sky...')
- test.assert_equals(fury_road(Interceptor(85, 130), PersuitVehicle(60, 55), True, True), 'The Nightrider, remember his name when you look into the night sky...')
- test.assert_equals(fury_road(Interceptor(120, 175), PersuitVehicle(100, 85), True, True), 'The Nightrider, remember his name when you look into the night sky...')
- @test.it("test case 2: The Nightrider evades capture")
- def test_case():
test.assert_equals(fury_road(Interceptor(100, 150), PersuitVehicle(100, 150), True), "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!")test.assert_equals(fury_road(Interceptor(121, 40), PersuitVehicle(120, 150), False), "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!")test.assert_equals(fury_road(Interceptor(155, 85), PersuitVehicle(5, 15), False), "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!")test.assert_equals(fury_road(Interceptor(185, 230), PersuitVehicle(5, 10), True), "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!")- test.assert_equals(fury_road(Interceptor(100, 150), PersuitVehicle(100, 150), True, False), "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!")
- test.assert_equals(fury_road(Interceptor(121, 40), PersuitVehicle(120, 150), False, True), "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!")
- test.assert_equals(fury_road(Interceptor(155, 85), PersuitVehicle(5, 15), False, True), "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!")
- test.assert_equals(fury_road(Interceptor(185, 230), PersuitVehicle(5, 10), True, False), "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!")
- test.assert_equals(fury_road(Interceptor(100, 150), PersuitVehicle(100, 150), True, False), "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!")
- @test.it("test case 3: Goose assist!")
- def test_case():
- test.assert_equals(fury_road(Interceptor(100, 150), PersuitVehicle(100, 150), False, True), "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!")
- test.assert_equals(fury_road(Interceptor(100, 150), PersuitVehicle(100, 150), True, True), "I am the Nightrider, I'm a rocker, I'm a roller, and I ain't never coming back!")
def or16(a, b): out = ['0'] * 16 for i in range(16): out[i] = max(a[i] , b[i]) return ''.join(out)
- def or16(a, b):
- out = ['0'] * 16
- for i in range(16):
out[i] = a[i] or b[i]- out[i] = max(a[i] , b[i])
- return ''.join(out)
import codewars_test as test from solution import or16 @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(or16('codewarz kumite!', 'python programer'), 'pythwnrzrouriter') test.assert_equals(or16('codewarz kumite!', 'cryptography 101'), 'crypworzapuyite1')
- import codewars_test as test
- from solution import or16
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
test.assert_equals(or16('codewarz kumite!', 'python programing'), 'codewarz kumite!')- test.assert_equals(or16('codewarz kumite!', 'python programer'), 'pythwnrzrouriter')
- test.assert_equals(or16('codewarz kumite!', 'cryptography 101'), 'crypworzapuyite1')
def greatest(lst): return int(''.join(sorted([str(n) for n in lst], reverse=True)))
from collections import Counter- def greatest(lst):
c=Counter(lst)acc=[]for n in (9,8,7,6,5,4,3,2,1,0):if n in c:acc.append(str(n)*c[n])acc="".join(acc)return int(acc) if acc else 0- return int(''.join(sorted([str(n) for n in lst], reverse=True)))
import codewars_test as test # TODO Write tests import solution # or from solution import example # test.assert_equals(actual, expected, [optional] message) @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(greatest([1,2,3,5,5,3,9,0,3,4,3]), 95543333210) test.assert_equals(greatest([6,6,6,7,7,0]), 776660)
- import codewars_test as test
- # TODO Write tests
- import solution # or from solution import example
- # 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(greatest([1,2,3,5,5,3,9,0,3,4,3]), 95543333210)- def test_case():
- test.assert_equals(greatest([1,2,3,5,5,3,9,0,3,4,3]), 95543333210)
- test.assert_equals(greatest([6,6,6,7,7,0]), 776660)
#include <iostream> using namespace std; int mai() { int x = 1; int u = 0, g = 0, c = 0; cout << "quanti anni ha l'uomo? (alla donna non si chiede)" << endl; cin >> u; while (x <= u) { if (x == 1) { g = 15; c = 15; } if (x == 2) { g += 9; c += 9; } if (x >= 3) { g += 4; c += 5; } x++; } cout << "cane " << c << endl; cout << "gatto " << g; return 0; }
- #include <iostream>
- using namespace std;
int main()- int mai()
- {
- int x = 1;
- int u = 0, g = 0, c = 0;
- cout << "quanti anni ha l'uomo? (alla donna non si chiede)" << endl;
- cin >> u;
- while (x <= u)
- {
- if (x == 1)
- {
- g = 15;
- c = 15;
- }
- if (x == 2) {
- g += 9;
- c += 9;
- }
- if (x >= 3) {
- g += 4;
- c += 5;
- }
- x++;
- }
- cout << "cane " << c << endl;
- cout << "gatto " << g;
- return 0;
- }
// TODO: Replace examples and use TDD by writing your own tests Describe(any_group_name_you_want) { It(should_do_something) { Assert::That("another value", Equals("another value")); Assert::That(mai(), Equals(0)); } };
- // TODO: Replace examples and use TDD by writing your own tests
- Describe(any_group_name_you_want)
- {
- It(should_do_something)
- {
Assert::That("some value", Equals("another value"));- Assert::That("another value", Equals("another value"));
- Assert::That(mai(), Equals(0));
- }
- };
import kotlin.test.Test import kotlin.test.assertEquals class ReturnIntTest { @Test fun `returnInt test`() { assertEquals(10.returnInt(), 10); } }
- import kotlin.test.Test
- import kotlin.test.assertEquals
- class ReturnIntTest {
- @Test
- fun `returnInt test`() {
assertEquals(returnInt(10), 10);- assertEquals(10.returnInt(), 10);
- }
- }