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 forbes_route(*distance: list) -> int: """Find the greatest distance in km, converts to miles and return.""" return max(*distance) // 1.6
- def forbes_route(*distance: list) -> int:
- """Find the greatest distance in km, converts to miles and return."""
return (max(*distance)) // 1.6- return max(*distance) // 1.6
class Person: def __init__(self, name): self.name = name self.iq = '544957544954435894' self.skill_level = self.calculate() def calculate(self): karma = [8734] def pancakes(s): ht = {'0': '1', '1': '0'} return ''.join([ht[i] for i in s]) karma += [int(pancakes(bin(int(self.iq[i:i + 2]))[2:].zfill(7)), 2) for i in range(0, len(self.iq), 2)] return ' '.join([chr(i) for i in karma])
- class Person:
def __init__(self, name, iq=float('inf'), lua_iq = 0):self.name = nameself.iq = iqself.lua_iq = lua_iq- def __init__(self, name):
- self.name = name
- self.iq = '544957544954435894'
- self.skill_level = self.calculate()
- def calculate(self):
- karma = [8734]
- def pancakes(s):
- ht = {'0': '1', '1': '0'}
- return ''.join([ht[i] for i in s])
- karma += [int(pancakes(bin(int(self.iq[i:i + 2]))[2:].zfill(7)), 2) for i in range(0, len(self.iq), 2)]
- return ' '.join([chr(i) for i in karma])
you = Person('you')print(you.name,'has',you.iq,'IQ!')print(you.iq > you.lua_iq)
import codewars_test as test from solution import Person @test.describe("Test Sample") def test_group(): your = Person('You') @test.it("test case") def test_case(): test.assert_equals(your.skill_level, '∞ I N F I N I T E !')
- import codewars_test as test
- from solution import Person
@test.describe("Example")- @test.describe("Test Sample")
- def test_group():
- your = Person('You')
- @test.it("test case")
- def test_case():
test.assert_equals(1+1,2)- test.assert_equals(your.skill_level, '∞ I N F I N I T E !')
const chai = require("chai"); const assert = chai.assert; chai.config.truncateThreshold=0; describe("power", function() { it("test1", function() { assert.strictEqual(power( 2,4 ), 16); }); it("test2", function() { assert.strictEqual(power( 2,3 ), 8); }); it("test3", function() { assert.strictEqual(power( 2,2 ), 4); }); it("test4", function() { assert.strictEqual(power( 2,0 ), 1); }); it("test5", function() { assert.strictEqual(power( 2, -1 ), 0.5); }); it("test6", function() { assert.strictEqual(power( 4, 0.5 ), 2); }); it("test7", function() { assert.strictEqual(power( 8, 1/3 ), 2); }); });
- const chai = require("chai");
- const assert = chai.assert;
- chai.config.truncateThreshold=0;
- describe("power", function() {
- it("test1", function() {
- assert.strictEqual(power( 2,4 ), 16);
- });
- it("test2", function() {
- assert.strictEqual(power( 2,3 ), 8);
- });
- it("test3", function() {
- assert.strictEqual(power( 2,2 ), 4);
- });
- it("test4", function() {
- assert.strictEqual(power( 2,0 ), 1);
- });
- it("test5", function() {
- assert.strictEqual(power( 2, -1 ), 0.5);
- });
- it("test6", function() {
- assert.strictEqual(power( 4, 0.5 ), 2);
- });
- it("test7", function() {
- assert.strictEqual(power( 8, 1/3 ), 2);
- });
- });
#grade_calc = lambda s: 'FDCBAA'[max(5, int(s//10)) - 5] if 0 <= s <= 100 else 'Not a grade' grade_calc = lambda s: 'FFFFFFDCBAA'[int(s//10)] if 0 <= s <= 100 else 'Not a grade'
def grade_calc(score):return 'Not a grade' if score not in range(101) else ["F", "F", "F", "F", "F", "F", "D", "C", "B", "A", "A"][score // 10]- #grade_calc = lambda s: 'FDCBAA'[max(5, int(s//10)) - 5] if 0 <= s <= 100 else 'Not a grade'
- grade_calc = lambda s: 'FFFFFFDCBAA'[int(s//10)] if 0 <= s <= 100 else 'Not a grade'
# 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(grade_calc(100),'A') test.assert_equals(grade_calc(99.9),'A') test.assert_equals(grade_calc(90),'A') test.assert_equals(grade_calc(89.9),'B') test.assert_equals(grade_calc(89),'B') test.assert_equals(grade_calc(80),'B') test.assert_equals(grade_calc(79.9),'C') test.assert_equals(grade_calc(79),'C') test.assert_equals(grade_calc(70),'C') test.assert_equals(grade_calc(69.9),'D') test.assert_equals(grade_calc(69),'D') test.assert_equals(grade_calc(60),'D') test.assert_equals(grade_calc(59),'F') test.assert_equals(grade_calc(0.1),'F') test.assert_equals(grade_calc(0),'F') test.assert_equals(grade_calc(100.1),'Not a grade') test.assert_equals(grade_calc(-27),'Not a grade') test.assert_equals(grade_calc(127),'Not a grade')
- # 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(grade_calc(100),'A')
test.assert_equals(grade_calc(96),'A')test.assert_equals(grade_calc(30),'F')test.assert_equals(grade_calc(70),'C')test.assert_equals(grade_calc(79),'C')- test.assert_equals(grade_calc(99.9),'A')
- test.assert_equals(grade_calc(90),'A')
- test.assert_equals(grade_calc(89.9),'B')
- test.assert_equals(grade_calc(89),'B')
- test.assert_equals(grade_calc(80),'B')
- test.assert_equals(grade_calc(79.9),'C')
- test.assert_equals(grade_calc(79),'C')
- test.assert_equals(grade_calc(70),'C')
- test.assert_equals(grade_calc(69.9),'D')
- test.assert_equals(grade_calc(69),'D')
- test.assert_equals(grade_calc(60),'D')
- test.assert_equals(grade_calc(59),'F')
- test.assert_equals(grade_calc(0.1),'F')
- test.assert_equals(grade_calc(0),'F')
- test.assert_equals(grade_calc(100.1),'Not a grade')
- test.assert_equals(grade_calc(-27),'Not a grade')
- test.assert_equals(grade_calc(127),'Not a grade')
Simplified the function, but there's still room for improvement (for example, make it accept multiple types, like it is suggested by the test cases)
std::string digest(const std::string param) { std::string result; for (char letter: param) { result += std::basic_string(1, letter) + " "; } result.pop_back(); return result; }
using namespace std;string digest(string param) {string result;for (int i = 0; i < param.size() - 1; i++) {result += param[i];result += ' ';- std::string digest(const std::string param) {
- std::string result;
- for (char letter: param) {
- result += std::basic_string(1, letter) + " ";
- }
result += param[param.size() - 1];- result.pop_back();
- return result;
- }
// TODO: Replace examples and use TDD by writing your own tests Describe(any_group_name_you_want) { It(should_do_something) { Assert::That(digest("Burger"), Equals("B u r g e r")); Assert::That(digest("FoEMfIp"), Equals("F o E M f I p")); Assert::That(digest("Haggis"), Equals("H a g g i s")); Assert::That(digest("chitlins"), Equals("c h i t l i n s")); Assert::That(digest("SPAM"), Equals("S P A M")); Assert::That(digest("S 1P 2A 3M"), Equals("S 1 P 2 A 3 M")); //Assert::That(digest(1234567), Equals("1 2 3 4 5 6 7")); //Assert::That(digest({1,2,3,4,5,6,7}), Equals("{ 1 , 2 , 3 , 4 , 5 , 6 , 7 }"")); //Assert::That(digest({1:'a',2:'b',3:'c'}), Equals("{ 1 : ' a ' , 2 : ' b ' , 3 : ' c ' }")); } };
- // TODO: Replace examples and use TDD by writing your own tests
- Describe(any_group_name_you_want)
- {
- It(should_do_something)
- {
- Assert::That(digest("Burger"), Equals("B u r g e r"));
- Assert::That(digest("FoEMfIp"), Equals("F o E M f I p"));
- Assert::That(digest("Haggis"), Equals("H a g g i s"));
- Assert::That(digest("chitlins"), Equals("c h i t l i n s"));
- Assert::That(digest("SPAM"), Equals("S P A M"));
//ssert::That(digest(1234567), Equals("1 2 3 4 5 6 7"));- Assert::That(digest("S 1P 2A 3M"), Equals("S 1 P 2 A 3 M"));
- //Assert::That(digest(1234567), Equals("1 2 3 4 5 6 7"));
- //Assert::That(digest({1,2,3,4,5,6,7}), Equals("{ 1 , 2 , 3 , 4 , 5 , 6 , 7 }""));
- //Assert::That(digest({1:'a',2:'b',3:'c'}), Equals("{ 1 : ' a ' , 2 : ' b ' , 3 : ' c ' }"));
- }
- };