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.
package kumite import "time" func CheckWorkHours(dateTime time.Time) bool { return dateTime.Weekday() != time.Thursday && dateTime.Weekday() != time.Sunday && dateTime.Hour() >= 8 && dateTime.Hour() < 18 }
- package kumite
- import "time"
- func CheckWorkHours(dateTime time.Time) bool {
return true &&dateTime.Weekday() != time.Thursday &&- return dateTime.Weekday() != time.Thursday &&
- dateTime.Weekday() != time.Sunday &&
- dateTime.Hour() >= 8 &&
- dateTime.Hour() < 18
- }
fn reverse_compliment(dna: &str) -> String { dna.chars() .rev() .map(|c| match c { 'A' => 'T', 'T' => 'A', 'C' => 'G', 'G' => 'C', _ => panic!("invalid nucleotide") }) .collect() }
def reverse_compliment(dna):pass- fn reverse_compliment(dna: &str) -> String {
- dna.chars()
- .rev()
- .map(|c| match c {
- 'A' => 'T',
- 'T' => 'A',
- 'C' => 'G',
- 'G' => 'C',
- _ => panic!("invalid nucleotide")
- })
- .collect()
- }
#[test] fn test_rev_comp_is_correct() { assert_eq!(reverse_compliment("A"), "T"); assert_eq!(reverse_compliment("ATG"), "CAT"); assert_eq!(reverse_compliment("GATCCCTATTGGATATCTAGCATCATA"), "TATGATGCTAGATATCCAATAGGGATC"); assert_eq!(reverse_compliment("ATGGCATGA"), "TCATGCCAT"); }
class MyTestCase(unittest.TestCase):def test_rev_comp_is_correct(self):self.assertEqual(reverse_compliment("A"), "T")self.assertEqual(reverse_compliment("ATG"), "CAT")self.assertEqual(reverse_compliment("GATCCCTATTGGATATCTAGCATCATA"), "TATGATGCTAGATATCCAATAGGGATC")self.assertEqual(reverse_compliment("ATGGCATGA"), "TCATGCCAT")- #[test]
- fn test_rev_comp_is_correct() {
- assert_eq!(reverse_compliment("A"), "T");
- assert_eq!(reverse_compliment("ATG"), "CAT");
- assert_eq!(reverse_compliment("GATCCCTATTGGATATCTAGCATCATA"), "TATGATGCTAGATATCCAATAGGGATC");
- assert_eq!(reverse_compliment("ATGGCATGA"), "TCATGCCAT");
- }
fn last_char(s: &str) -> char { s.chars().last().unwrap() }
def last_char(str):return str[-1]- fn last_char(s: &str) -> char {
- s.chars().last().unwrap()
- }
#[test] fn test() { assert_eq!(last_char("rust"), 't'); assert_eq!(last_char("utrs"), 's'); }
# TODO: Replace examples and use TDD development by writing your own tests# These are some of the methods available:# test.expect(boolean, [optional] message)# test.assert_equals(actual, expected, [optional] message)# test.assert_not_equals(actual, expected, [optional] message)# You can use Test.describe and Test.it to write BDD style test groupingstest.describe("Basic Test: ")test.assert_equals(last_char('python'), 'n', 'results not equal to n')test.describe("Random Test: ")test.assert_equals(last_char('nhptyo'), 'o', 'results not equal to o')- #[test]
- fn test() {
- assert_eq!(last_char("rust"), 't');
- assert_eq!(last_char("utrs"), 's');
- }
fn minutes(n: u32) -> String { format!("{}:{:02}", n / 60, n % 60) }
function minutes(num){return num % 60 < 10 ? Math.floor(num/60) + ':' + '0' + (num % 60) : Math.floor(num/60) + ':' + (num % 60)- fn minutes(n: u32) -> String {
- format!("{}:{:02}", n / 60, n % 60)
- }
#[test] fn test() { assert_eq!(minutes(0), "0:00"); assert_eq!(minutes(1), "0:01"); assert_eq!(minutes(18), "0:18"); assert_eq!(minutes(13267), "221:07"); assert_eq!(minutes(985), "16:25"); assert_eq!(minutes(351), "5:51"); assert_eq!(minutes(156113), "2601:53"); }
describe("Solution", function(){it("Did you make the correct conversion?", function(){Test.assertEquals(minutes(0), "0:00", "better try again");Test.assertEquals(minutes(1), "0:01", "better try again");Test.assertEquals(minutes(18), "0:18", "better try again");Test.assertEquals(minutes(13267), "221:07", "better try again");Test.assertEquals(minutes(985), "16:25", "better try again");Test.assertEquals(minutes(351), "5:51", "better try again");Test.assertEquals(minutes(156113), "2601:53", "better try again");});});- #[test]
- fn test() {
- assert_eq!(minutes(0), "0:00");
- assert_eq!(minutes(1), "0:01");
- assert_eq!(minutes(18), "0:18");
- assert_eq!(minutes(13267), "221:07");
- assert_eq!(minutes(985), "16:25");
- assert_eq!(minutes(351), "5:51");
- assert_eq!(minutes(156113), "2601:53");
- }
fn bigger_num(a: i32, b: i32) -> i32 { a.max(b) }
public class BiggerNum{public static int compare(int a, int b) {return 0;}- fn bigger_num(a: i32, b: i32) -> i32 {
- a.max(b)
- }
#[test] fn test() { assert_eq!(bigger_num(10, 5), 10); }
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 testSomething() {int a = 10;int b = 5;//assertEquals(10, BiggerNum.compare(a, b));}- #[test]
- fn test() {
- assert_eq!(bigger_num(10, 5), 10);
- }
use std::ops::Add; use num::Zero; fn sum<T, S>(arr: T) -> S where T: IntoIterator<Item = S>, S: Add<Output = S> + Zero { let mut sum: S = Zero::zero(); for i in arr { sum = sum + i; } return sum; }
def sum(arr):result = 0for i in arr:result += ireturn result- use std::ops::Add;
- use num::Zero;
- fn sum<T, S>(arr: T) -> S where T: IntoIterator<Item = S>, S: Add<Output = S> + Zero {
- let mut sum: S = Zero::zero();
- for i in arr {
- sum = sum + i;
- }
- return sum;
- }
#[cfg(test)] mod tests { use super::*; use std::collections::*; #[test] fn test_sum() { assert_eq!(sum([1]), 1); assert_eq!(sum(Vec::from([3, 1])), 4); assert_eq!(sum(LinkedList::from([1, 2, 3])), 6); } }
import codewars_test as test# TODO Write testsfrom solution import sum- #[cfg(test)]
- mod tests {
- use super::*;
- use std::collections::*;
# test.assert_equals(actual, expected, [optional] message)@test.describe("Example tests")def test_group():@test.it("Basic tests")def test_case():test.assert_equals(sum([1]), 1)test.assert_equals(sum([1,2,3]), 6)- #[test]
- fn test_sum() {
- assert_eq!(sum([1]), 1);
- assert_eq!(sum(Vec::from([3, 1])), 4);
- assert_eq!(sum(LinkedList::from([1, 2, 3])), 6);
- }
- }
use std::io::*; fn kashikashi() -> Result<()> { const BUFF: [u8; 7] = [104, 101, 108, 108, 111, 10, 55]; return stdout().write_all(&BUFF); }
print("hello")print(2+5)- use std::io::*;
- fn kashikashi() -> Result<()> {
- const BUFF: [u8; 7] = [104, 101, 108, 108, 111, 10, 55];
- return stdout().write_all(&BUFF);
- }
// Add your tests here. // See https://doc.rust-lang.org/stable/rust-by-example/testing/unit_testing.html #[cfg(test)] mod tests { use super::*; #[test] fn test_kashikashi() { assert!(kashikashi().is_ok()); assert_eq!(2 + 2, 4); } }
import codewars_test as test# TODO Write testsimport solution # or from solution import example- // Add your tests here.
- // See https://doc.rust-lang.org/stable/rust-by-example/testing/unit_testing.html
# 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)- #[cfg(test)]
- mod tests {
- use super::*;
- #[test]
- fn test_kashikashi() {
- assert!(kashikashi().is_ok());
- assert_eq!(2 + 2, 4);
- }
- }
fn digest(food: &str) -> String { food.chars() .map(Into::into) .collect::<Vec<String>>() .join(" ") }
def digest(food):return " ".join(food)- fn digest(food: &str) -> String {
- food.chars()
- .map(Into::into)
- .collect::<Vec<String>>()
- .join(" ")
- }
#[test] fn test() { assert_eq!(digest("Burger"), "B u r g e r"); assert_eq!(digest("FoEMfIp"), "F o E M f I p"); }
import codewars_test as test# TODO Write testsimport solution # or from solution import example# test.assert_equals(actual, expected, [optional] message)@test.describe("Example Tests")def test_group():@test.it("Food")def test_case():test.assert_equals(digest("Burger"), "B u r g e r")@test.it("Gibberish")def gibberish():test.assert_equals(digest("FoEMfIp"), "F o E M f I p")- #[test]
- fn test() {
- assert_eq!(digest("Burger"), "B u r g e r");
- assert_eq!(digest("FoEMfIp"), "F o E M f I p");
- }