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.
(ns reverseint.core) (defn reverse-int' [acc x] (let [quot-rem (.divideAndRemainder x java.math.BigInteger/TEN)] (if (= (nth quot-rem 0) 0) (+ (* 10 acc) (nth quot-rem 1)) (reverse-int' (+ (* 10 acc) (nth quot-rem 1)) (nth quot-rem 0))))) (defn reverse-int [n] (let [quot-rem (.divideAndRemainder (biginteger n) java.math.BigInteger/TEN)] (reverse-int' (nth quot-rem 1) (nth quot-rem 0))))
public class Algorithms {public static int reverseInt(int n) {int reversed = 0;while(n != 0){reversed = reversed * 10 + (n % 10);n /= 10;}return reversed;}}- (ns reverseint.core)
- (defn reverse-int' [acc x]
- (let [quot-rem (.divideAndRemainder
- x
- java.math.BigInteger/TEN)]
- (if (= (nth quot-rem 0) 0) (+ (* 10 acc) (nth quot-rem 1))
- (reverse-int' (+ (* 10 acc) (nth quot-rem 1)) (nth quot-rem 0)))))
- (defn reverse-int [n]
- (let [quot-rem (.divideAndRemainder
- (biginteger n)
- java.math.BigInteger/TEN)]
- (reverse-int' (nth quot-rem 1) (nth quot-rem 0))))
(ns reverseint.test (:require [clojure.test :refer :all] [reverseint.core :refer [reverse-int]])) (deftest reverse-int-test (is (= (reverse-int 12345) 54321)) (is (= (reverse-int 0) 0)))
import org.junit.Test;import static org.junit.Assert.assertEquals;import org.junit.runners.JUnit4;// TODO: Replace examples and use TDD development by writing your own testspublic class SolutionTest {@Testpublic void reverseIntTest() {assertEquals(54321, Algorithms.reverseInt(12345));}}- (ns reverseint.test
- (:require [clojure.test :refer :all]
- [reverseint.core :refer [reverse-int]]))
- (deftest reverse-int-test
- (is (= (reverse-int 12345) 54321))
- (is (= (reverse-int 0) 0)))
#include <bitset> #define KATA_SUBSCRIPT namespace Kata { bool IsOdd(int input) { return std::bitset<1>(input) #if defined KATA_EQUALS == std::bitset<1>(1); #elif defined KATA_NOT_EQUALS != std::bitset<1>(0); #elif defined KATA_SUBSCRIPT [0]; #elif defined KATA_TEST .test(0); #elif defined KATA_ALL .all(); #elif defined KATA_ANY .any(); #elif defined KATA_NONE .none() != true; #elif defined KATA_COUNT .count(); #elif defined KATA_TO_STRING .to_string() == "1"; #elif defined KATA_TO_ULONG .to_ulong(); #elif defined KATA_TO_ULLONG .to_ullong(); #else you have to choose something #endif } }
public static class Kata- #include <bitset>
- #define KATA_SUBSCRIPT
- namespace Kata
- {
public static bool IsOdd(int input)- bool IsOdd(int input)
- {
return ((input % 10 == 1) || (input % 10 == 3) || (input % 10 == 5) || (input % 10 == 7) || (input % 10 == 9));- return std::bitset<1>(input)
- #if defined KATA_EQUALS
- == std::bitset<1>(1);
- #elif defined KATA_NOT_EQUALS
- != std::bitset<1>(0);
- #elif defined KATA_SUBSCRIPT
- [0];
- #elif defined KATA_TEST
- .test(0);
- #elif defined KATA_ALL
- .all();
- #elif defined KATA_ANY
- .any();
- #elif defined KATA_NONE
- .none() != true;
- #elif defined KATA_COUNT
- .count();
- #elif defined KATA_TO_STRING
- .to_string() == "1";
- #elif defined KATA_TO_ULONG
- .to_ulong();
- #elif defined KATA_TO_ULLONG
- .to_ullong();
- #else
- you have to choose something
- #endif
- }
- }
// TODO: Replace examples and use TDD by writing your own tests Describe(any_group_name_you_want) { It(should_do_something) { Assert::That(Kata::IsOdd(1), Equals(true)); Assert::That(Kata::IsOdd(2), Equals(false)); Assert::That(Kata::IsOdd(13), Equals(true)); Assert::That(Kata::IsOdd(18284), Equals(false)); Assert::That(Kata::IsOdd(-5), Equals(true)); Assert::That(Kata::IsOdd(-6), Equals(false)); } };
namespace Solution {using NUnit.Framework;using System;- // TODO: Replace examples and use TDD by writing your own tests
// TODO: Replace examples and use TDD by writing your own tests[TestFixture]public class SolutionTest{[Test]public void MyTest()- Describe(any_group_name_you_want)
- {
- It(should_do_something)
- {
Assert.AreEqual(true, Kata.IsOdd(1));Assert.AreEqual(false, Kata.IsOdd(2));Assert.AreEqual(true, Kata.IsOdd(13));Assert.AreEqual(false, Kata.IsOdd(18284));- Assert::That(Kata::IsOdd(1), Equals(true));
- Assert::That(Kata::IsOdd(2), Equals(false));
- Assert::That(Kata::IsOdd(13), Equals(true));
- Assert::That(Kata::IsOdd(18284), Equals(false));
- Assert::That(Kata::IsOdd(-5), Equals(true));
- Assert::That(Kata::IsOdd(-6), Equals(false));
- }
}}- };
def Hello_Python(a='Hello',b='Python!'): return a + b
System.Console.WriteLine("Hello, C#!");- def Hello_Python(a='Hello',b='Python!'):
- return a + b
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('Hello ' + 'Python!', 'Hello Python!')
- 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('Hello ' + 'Python!', 'Hello Python!')
add = +
// write a add function that doesn't use the plus symbolfunction add(a, b){return a + b;}// Make sure to view the test cases to see how this test fails- add = +
using FactCheck facts("Basic tests") do @fact occursin('+', join(readlines("/workspace/solution.txt"))) --> false "shouldn't contain +" @fact add(1, 2) --> 3 end
const fs = require('fs');const solution = fs.readFileSync('/home/codewarrior/solution.txt', 'utf8');- using FactCheck
describe("Check Solution", function(){it("should prevent the '+' symbol from being used anywhere in the code", function(){Test.expect(solution.indexOf('+') == -1, "Your code isn't allowed to include the + symbol!");});});- facts("Basic tests") do
- @fact occursin('+', join(readlines("/workspace/solution.txt"))) --> false "shouldn't contain +"
- @fact add(1, 2) --> 3
- end
function monteCarlo() { return new Promise(function (resolve, reject) { reject({server: 'down'}); }); } async function main() { // converter para ES6 try{ const results = await monteCarlo(); }catch(e) { } return true; }
- function monteCarlo() {
- return new Promise(function (resolve, reject) {
- reject({server: 'down'});
- });
- }
- async function main() {
- // converter para ES6
const results = await monteCarlo();- try{
- const results = await monteCarlo();
- }catch(e) {
- }
- return true;
- }
function monteCarlo() { return new Promise(function (resolve, reject) { resolve([{ titulo: 'UOL - O Melhor conteúdo' }]); }); } async function main() { const response = await monteCarlo() return true; }
- function monteCarlo() {
- return new Promise(function (resolve, reject) {
- resolve([{
- titulo: 'UOL - O Melhor conteúdo'
- }]);
- });
- }
- async function main() {
// converter para ES6monteCarlo().then(function(response) {console.log(response)});- const response = await monteCarlo()
- return true;
- }
const main = () => { let a = [1, 2, 3]; let b = [4, 5, 6]; let c = [7, 8, 9]; // converter para ES6 var d = a.concat(b).concat(c); return [...a,...b,...c].join(','); }
- const main = () => {
- let a = [1, 2, 3];
- let b = [4, 5, 6];
- let c = [7, 8, 9];
- // converter para ES6
- var d = a.concat(b).concat(c);
return d.join(',');- return [...a,...b,...c].join(',');
- }
var materia = { conteudo: { titulo: 'UOL', }, tags: ['São Paulo', 'SP', 'Sudeste', 'Brasil', 'América Latina'] }; const {conteudo: {titulo}, tags: {uf, regiao}} = materia;
- var materia = {
- conteudo: {
- titulo: 'UOL',
- },
- tags: ['São Paulo', 'SP', 'Sudeste', 'Brasil', 'América Latina']
- };
var uf = materia.tags[1];var regiao = materia.tags[2];var titulo = materia.conteudo.titulo;- const {conteudo: {titulo}, tags: {uf, regiao}} = materia;