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 multiply(a,b):
result = a*b
return result
res = multiply (5,10)
print(res)
func gradeCalc(_ score: Int) -> String { (score < 0 || score > 100) ? "Not a grade" : String(Array("FFFFFFDCBAA")[score / 10]); }
- func gradeCalc(_ score: Int) -> String {
(score < 0 || score > 100) ? "Not a grade" : ["F","F","F","F","F","F","D","C","B","A","A"][score / 10];- (score < 0 || score > 100) ? "Not a grade" : String(Array("FFFFFFDCBAA")[score / 10]);
- }
const cinema_auditorium = (spisok2D,ryad)=> { var soldTickets = 0; for (var i = 0; i < spisok2D[ryad].length; i++){ if (spisok2D[ryad][i] !== 0){ soldTickets++ } } return soldTickets; }
- const cinema_auditorium = (spisok2D,ryad)=> {
console.log(spisok2D,ryad)return 3- var soldTickets = 0;
- for (var i = 0; i < spisok2D[ryad].length; i++){
- if (spisok2D[ryad][i] !== 0){
- soldTickets++
- }
- }
- return soldTickets;
- }
function sumNechet(a, b) { let sum = 0; function нечетное(x){ return x % 2 !== 0; } for (let i = a; i <= b; i++){ if(нечетное(i)){ sum += i; } } return sum }
- function sumNechet(a, b) {
- let sum = 0;
- function нечетное(x){
- return x % 2 !== 0;
- }
- for (let i = a; i <= b; i++){
- if(нечетное(i)){
- sum += i;
- }
- }
- return sum
- }
function нечетное(число) {}
fn longest_string(strings: &str) -> &str { strings .split(',') .map(|s| s.trim()) .filter(|s| s.chars().all(|c| c.is_ascii_alphanumeric())) .max_by_key(|s| s.len()) .unwrap_or("") }
def lenght_line(line='marry, ksnfgjji233jc, harry!@#'):return 'ksnfgjji233jc,'- fn longest_string(strings: &str) -> &str {
- strings
- .split(',')
- .map(|s| s.trim())
- .filter(|s| s.chars().all(|c| c.is_ascii_alphanumeric()))
- .max_by_key(|s| s.len())
- .unwrap_or("")
- }
#[test] fn test() { assert_eq!(longest_string(""), ""); assert_eq!(longest_string(" "), ""); assert_eq!(longest_string(", ,"), ""); assert_eq!(longest_string(", test"), "test"); assert_eq!(longest_string(" somuchspacing "), "somuchspacing"); assert_eq!(longest_string("short, longer, longest_but_invalid"), "longer"); assert_eq!(longest_string("marry, ksnfgjji233jc, harry!@#"), "ksnfgjji233jc"); assert_eq!(longest_string("pilsnərRebesque,complex,trig0n0metry , abba is the best ,"), "trig0n0metry"); }
import codewars_test as test# TODO Write testsimport 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(lenght_line(), 'ksnfgjji233jc,')- #[test]
- fn test() {
- assert_eq!(longest_string(""), "");
- assert_eq!(longest_string(" "), "");
- assert_eq!(longest_string(", ,"), "");
- assert_eq!(longest_string(", test"), "test");
- assert_eq!(longest_string(" somuchspacing "), "somuchspacing");
- assert_eq!(longest_string("short, longer, longest_but_invalid"), "longer");
- assert_eq!(longest_string("marry, ksnfgjji233jc, harry!@#"), "ksnfgjji233jc");
- assert_eq!(longest_string("pilsnərRebesque,complex,trig0n0metry , abba is the best ,"), "trig0n0metry");
- }
fn converter(n: u8) -> &'static str { match n { 0 => "zero", 1 => "one", 2 => "two", 3 => "three", 4 => "four", 5 => "five", 6 => "six", 7 => "seven", 8 => "eight", 9 => "nine", _ => panic!() } }
def converter(number):if number == 0:return "zero"elif number == 5:return "five"return number- fn converter(n: u8) -> &'static str {
- match n {
- 0 => "zero",
- 1 => "one",
- 2 => "two",
- 3 => "three",
- 4 => "four",
- 5 => "five",
- 6 => "six",
- 7 => "seven",
- 8 => "eight",
- 9 => "nine",
- _ => panic!()
- }
- }
#[test] fn test() { assert_eq!(converter(0), "zero"); assert_eq!(converter(1), "one"); assert_eq!(converter(2), "two"); assert_eq!(converter(3), "three"); assert_eq!(converter(4), "four"); assert_eq!(converter(5), "five"); assert_eq!(converter(6), "six"); assert_eq!(converter(7), "seven"); assert_eq!(converter(8), "eight"); assert_eq!(converter(9), "nine"); }
import codewars_test as test# TODO Write testsimport 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(solution.converter(0), "zero")test.assert_equals(solution.converter(5), "five")- #[test]
- fn test() {
- assert_eq!(converter(0), "zero");
- assert_eq!(converter(1), "one");
- assert_eq!(converter(2), "two");
- assert_eq!(converter(3), "three");
- assert_eq!(converter(4), "four");
- assert_eq!(converter(5), "five");
- assert_eq!(converter(6), "six");
- assert_eq!(converter(7), "seven");
- assert_eq!(converter(8), "eight");
- assert_eq!(converter(9), "nine");
- }
fn nand(a: bool, b: bool) -> bool { !(a && b) } fn not(a: bool) -> bool { nand(a, a) } fn and(a: bool, b: bool) -> bool { not(nand(a, b)) } fn or(a: bool, b: bool) -> bool { nand(not(a), not(b)) } fn xor(a: bool, b: bool) -> bool { and(nand(a, b), or(a, b)) } fn nor(a: bool, b: bool) -> bool { and(not(a), not(b)) }
bool Or(bool a, bool b){if(!a){if(!b){return false;}}return true;- fn nand(a: bool, b: bool) -> bool {
- !(a && b)
- }
bool Xor(bool a, bool b){return a != b;- fn not(a: bool) -> bool {
- nand(a, a)
- }
bool And(bool a, bool b){if(a){if(b){return true;}}return false;- fn and(a: bool, b: bool) -> bool {
- not(nand(a, b))
- }
- fn or(a: bool, b: bool) -> bool {
- nand(not(a), not(b))
- }
- fn xor(a: bool, b: bool) -> bool {
- and(nand(a, b), or(a, b))
- }
- fn nor(a: bool, b: bool) -> bool {
- and(not(a), not(b))
- }
#[cfg(test)] mod tests { use super::*; #[test] fn test_not() { assert_eq!(not(false), true); assert_eq!(not(true), false); } #[test] fn test_and() { assert_eq!(and(false, false), false); assert_eq!(and(true, false), false); assert_eq!(and(false, true), false); assert_eq!(and(true, true), true); } #[test] fn test_or() { assert_eq!(or(false, false), false); assert_eq!(or(true, false), true); assert_eq!(or(false, true), true); assert_eq!(or(true, true), true); } #[test] fn test_xor() { assert_eq!(xor(false, false), false); assert_eq!(xor(true, false), true); assert_eq!(xor(false, true), true); assert_eq!(xor(true, true), false); } #[test] fn test_nor() { assert_eq!(nor(false, false), true); assert_eq!(nor(true, false), false); assert_eq!(nor(false, true), false); assert_eq!(nor(true, true), false); } }
// TODO: Replace examples and use TDD development by writing your own testsDescribe(AND_OR_XOR){It(AND){Assert::That(And(true, false), Equals(false));Assert::That(And(false, true), Equals(false));Assert::That(And(true, true), Equals(true));Assert::That(And(false, false), Equals(false));- #[cfg(test)]
- mod tests {
- use super::*;
- #[test]
- fn test_not() {
- assert_eq!(not(false), true);
- assert_eq!(not(true), false);
- }
It(OR){Assert::That(Or(true, false), Equals(true));Assert::That(Or(false, true), Equals(true));Assert::That(Or(true, true), Equals(true));Assert::That(Or(false, false), Equals(false));- #[test]
- fn test_and() {
- assert_eq!(and(false, false), false);
- assert_eq!(and(true, false), false);
- assert_eq!(and(false, true), false);
- assert_eq!(and(true, true), true);
- }
It(XOR){Assert::That(Xor(true, false), Equals(true));Assert::That(Xor(false, true), Equals(true));Assert::That(Xor(true, true), Equals(false));Assert::That(Xor(false, false), Equals(false));- #[test]
- fn test_or() {
- assert_eq!(or(false, false), false);
- assert_eq!(or(true, false), true);
- assert_eq!(or(false, true), true);
- assert_eq!(or(true, true), true);
- }
};- #[test]
- fn test_xor() {
- assert_eq!(xor(false, false), false);
- assert_eq!(xor(true, false), true);
- assert_eq!(xor(false, true), true);
- assert_eq!(xor(true, true), false);
- }
- #[test]
- fn test_nor() {
- assert_eq!(nor(false, false), true);
- assert_eq!(nor(true, false), false);
- assert_eq!(nor(false, true), false);
- assert_eq!(nor(true, true), false);
- }
- }
fn fizzbuzzy(n: u32) -> u32 { n/3 + n/5 + 2 }
function fizzbuzzy(n) {//insert code here- fn fizzbuzzy(n: u32) -> u32 {
- n/3 + n/5 + 2
- }
#[test] fn test() { assert_eq!(fizzbuzzy(21), 13); assert_eq!(fizzbuzzy(99), 54); }
Test.assertEquals(fizzbuzzy(21), 13, "21 miles needs 13 cones")Test.assertEquals(fizzbuzzy(99), 54, "99 miles needs 54 cones")- #[test]
- fn test() {
- assert_eq!(fizzbuzzy(21), 13);
- assert_eq!(fizzbuzzy(99), 54);
- }
fn remove<T>(mut arr: Vec<T>, n: usize) -> Vec<T> { if n < arr.len() { arr.remove(n); } arr }
function remove (arr, n) {if (n < 0 || n >= arr.length) return arr;arr.splice(n, 1);return arr;- fn remove<T>(mut arr: Vec<T>, n: usize) -> Vec<T> {
- if n < arr.len() {
- arr.remove(n);
- }
- arr
- }
#[cfg(test)] mod tests { use super::*; #[test] fn test_correct() { assert_eq!( remove(vec![1, 2, 3], 2), vec![1, 2] ); assert_eq!( remove(vec![1, 2, 3, 4, 5, 6, 2, 1, 5, 3], 8), vec![1, 2, 3, 4, 5, 6, 2, 1, 3] ); assert_eq!( remove(vec!["1,2,3,4,5", "test", "7", "{obj: \"obj\"}", "[8,2,5]"], 3), vec!["1,2,3,4,5", "test", "7", "[8,2,5]"] ); assert_eq!( remove(vec!["dog", "cat", "bat", "parrot", "monkey"], 4), vec!["dog", "cat", "bat", "parrot"] ); } #[test] fn test_wrong() { assert_eq!( remove(vec![1, 2, 3], 20), vec![1, 2, 3] ); assert_eq!( remove(vec![1, 2, 3, 4, 5, 6, 2, 1, 5, 3], 17), vec![1, 2, 3, 4, 5, 6, 2, 1, 5, 3] ); assert_eq!( remove(vec!["1,2,3,4,5", "test", "7", "{obj: \"obj\"}", "[8,2,5]"], 19), vec!["1,2,3,4,5", "test", "7", "{obj: \"obj\"}", "[8,2,5]"] ); assert_eq!( remove(vec!["dog", "cat", "bat", "parrot", "monkey"], 101), vec!["dog", "cat", "bat", "parrot", "monkey"] ); } }
// TODO: Replace examples and use TDD development by writing your own tests// These are some CW specific test methods available:// Test.expect(boolean, [optional] message)// Test.assertEquals(actual, expected, [optional] message)// Test.assertSimilar(actual, expected, [optional] message)// Test.assertNotEquals(actual, expected, [optional] message)// NodeJS assert is also automatically required for you.// assert(true)// assert.strictEqual({a: 1}, {a: 1})// assert.deepEqual({a: [{b: 1}]}, {a: [{b: 1}]})// You can also use Chai (http://chaijs.com/) by requiring it yourself// var expect = require("chai").expect;// var assert = require("chai").assert;// require("chai").should();describe("Solution", function(){it("should remove the correct element", function(){Test.assertSimilar(remove([1, 2, 3], 2), [1, 2], "Wrong! Try again.");Test.assertSimilar(remove([1, 2, 3, 4, 5, 6, 2, 1, 5, 3], 8), [1, 2, 3, 4, 5, 6, 2, 1, 3], "Wrong! Try again.");Test.assertSimilar(remove(["1,2,3,4,5", "test", 7, {obj: "obj"}, [8,2,5]], 3), ["1,2,3,4,5", "test", 7, [8,2,5]], "Wrong! Try again.");Test.assertSimilar(remove(["dog", "cat", "bat", "parrot", "monkey"], 4), ["dog", "cat", "bat", "parrot"], "Wrong! Try again.");});it("should return original array if index is out of range", function(){Test.assertSimilar(remove([1, 2, 3], 20), [1, 2, 3], "Wrong! Try again.");Test.assertSimilar(remove([1, 2, 3, 4, 5, 6, 2, 1, 5, 3], 17), [1, 2, 3, 4, 5, 6, 2, 1, 5, 3], "Wrong! Try again.");Test.assertSimilar(remove(["1,2,3,4,5", "test", 7, {obj: "obj"}, [8,2,5]], -19), ["1,2,3,4,5", "test", 7, {obj: "obj"}, [8,2,5]], "Wrong! Try again.");Test.assertSimilar(remove(["dog", "cat", "bat", "parrot", "monkey"], -1), ["dog", "cat", "bat", "parrot", "monkey"], "Wrong! Try again.");});});- #[cfg(test)]
- mod tests {
- use super::*;
- #[test]
- fn test_correct() {
- assert_eq!(
- remove(vec![1, 2, 3], 2),
- vec![1, 2]
- );
- assert_eq!(
- remove(vec![1, 2, 3, 4, 5, 6, 2, 1, 5, 3], 8),
- vec![1, 2, 3, 4, 5, 6, 2, 1, 3]
- );
- assert_eq!(
- remove(vec!["1,2,3,4,5", "test", "7", "{obj: \"obj\"}", "[8,2,5]"], 3),
- vec!["1,2,3,4,5", "test", "7", "[8,2,5]"]
- );
- assert_eq!(
- remove(vec!["dog", "cat", "bat", "parrot", "monkey"], 4),
- vec!["dog", "cat", "bat", "parrot"]
- );
- }
- #[test]
- fn test_wrong() {
- assert_eq!(
- remove(vec![1, 2, 3], 20),
- vec![1, 2, 3]
- );
- assert_eq!(
- remove(vec![1, 2, 3, 4, 5, 6, 2, 1, 5, 3], 17),
- vec![1, 2, 3, 4, 5, 6, 2, 1, 5, 3]
- );
- assert_eq!(
- remove(vec!["1,2,3,4,5", "test", "7", "{obj: \"obj\"}", "[8,2,5]"], 19),
- vec!["1,2,3,4,5", "test", "7", "{obj: \"obj\"}", "[8,2,5]"]
- );
- assert_eq!(
- remove(vec!["dog", "cat", "bat", "parrot", "monkey"], 101),
- vec!["dog", "cat", "bat", "parrot", "monkey"]
- );
- }
- }