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.
#[cfg(test)] mod tests { use super::*; #[test] fn test_even_numbers_in_array() { let v = &[-567, 2, 100, -34, 1000, 99, 101, -1000, 200, 7, -100]; let r = v.iter().fold(0, |count, &num| count + (num & 1 == 0) as usize); assert_eq!(calculate_even_numbers(v), r); } #[test] fn test_empty_array() { assert_eq!(calculate_even_numbers(&[]), 0); } #[test] fn test_no_even_numbers() { let v = &[5, 7, 9, 1, 21, 33, 77, 57, 33, 91, 111, 23451]; assert_eq!(calculate_even_numbers(v), 0); } #[test] fn test_multiple_even_numbers() { let v = &[60, 180, 99, 100, 101, 103]; assert_eq!(calculate_even_numbers(v), 3); } #[test] fn test_large_numbers() { let v = &[10_000_000, 90_000, 700_000_000, 2, 70, 44]; assert_eq!(calculate_even_numbers(v), 6); } }
#[test]fn test() {assert_eq!(calculate_even_numbers(&[]), 0);assert_eq!(calculate_even_numbers(&[5, 7, 2, 4, 9]), 2);assert_eq!(calculate_even_numbers(&[60, 180, 99, 100, 101, 103]), 3);assert_eq!(calculate_even_numbers(&[99, 9, 1, 21, 33, 77, 57, 33, 91, 111, 23451]), 0);assert_eq!(calculate_even_numbers(&[10_000_000, 90_000, 700_000_000, 2, 70, 44]), 6);- #[cfg(test)]
- mod tests {
- use super::*;
- #[test]
- fn test_even_numbers_in_array() {
- let v = &[-567, 2, 100, -34, 1000, 99, 101, -1000, 200, 7, -100];
- let r = v.iter().fold(0, |count, &num| count + (num & 1 == 0) as usize);
- assert_eq!(calculate_even_numbers(v), r);
- }
- #[test]
- fn test_empty_array() {
- assert_eq!(calculate_even_numbers(&[]), 0);
- }
- #[test]
- fn test_no_even_numbers() {
- let v = &[5, 7, 9, 1, 21, 33, 77, 57, 33, 91, 111, 23451];
- assert_eq!(calculate_even_numbers(v), 0);
- }
- #[test]
- fn test_multiple_even_numbers() {
- let v = &[60, 180, 99, 100, 101, 103];
- assert_eq!(calculate_even_numbers(v), 3);
- }
- #[test]
- fn test_large_numbers() {
- let v = &[10_000_000, 90_000, 700_000_000, 2, 70, 44];
- assert_eq!(calculate_even_numbers(v), 6);
- }
- }
const tab = (func, start, end, step) => { let sum = 0; const count = Math.ceil((end - start) / step) + 1; for (let i = 0; i < count; i++) { sum += func(start + i * step); } return sum; }
const tab = (f, a, b, h) => {return Array.from({length: Math.ceil((b - a) / h) + 1},(v, i) => f(a + (i * h))).reduce((a, c) => a += c, 0)}- const tab = (func, start, end, step) => {
- let sum = 0;
- const count = Math.ceil((end - start) / step) + 1;
- for (let i = 0; i < count; i++) {
- sum += func(start + i * step);
- }
- return sum;
- }
#include <stdbool.h> bool odd_even(int n) { return n < 0 || n > 1 ? odd_even(n + 2 * (n < 0 ? 1 : -1)) : !n; }
- #include <stdbool.h>
- bool odd_even(int n)
- {
int r = 0, p[1] = {0};goto owo;uwu:*&*p = (&r)[0];goto miau;owo:*(int*)((void*)&r) = n%2;goto uwu;miau:return !(*p&1) ? true : false;- return n < 0 || n > 1 ? odd_even(n + 2 * (n < 0 ? 1 : -1)) : !n;
- }
#include <stdlib.h> #include <string.h> char *fanis(char *r, int k) { char *w = malloc(strlen(r) + 1), *p = w; while(w && *r) *p++ = k + *r++; return w; }
- #include <stdlib.h>
- #include <string.h>
char *fanis(char* r, int k) {char *w = malloc(strlen(r)+1);if (!w)- char *fanis(char *r, int k) {
- char *w = malloc(strlen(r) + 1), *p = w;
- while(w && *r) *p++ = k + *r++;
- return w;
char *p = w;while (*r)*p++ = k + *r++;return w;- }
using System; public static class Kata { public static int SameCase(char a, char b) { var aZ = a <= 'Z'; var bZ = b <= 'Z'; var aIsLetter = a >= 'A' && a <= 'z' && (aZ || a >= 'a'); if (aIsLetter != (b >= 'A' && b <= 'z' && (bZ || b >= 'a'))) return -1; return (!aIsLetter || aZ == bZ) ? 1 : 0; } }
- using System;
- public static class Kata
- {
- public static int SameCase(char a, char b)
- {
if (!char.IsLetter(a) && !char.IsLetter(b))return 1;if (!char.IsLetter(a) || !char.IsLetter(b))return -1;return (char.IsUpper(a) == char.IsUpper(b)) ? 1 : 0;- var aZ = a <= 'Z';
- var bZ = b <= 'Z';
- var aIsLetter = a >= 'A' && a <= 'z' && (aZ || a >= 'a');
- if (aIsLetter != (b >= 'A' && b <= 'z' && (bZ || b >= 'a'))) return -1;
- return (!aIsLetter || aZ == bZ) ? 1 : 0;
- }
- }
namespace Solution { using NUnit.Framework; using System; [TestFixture] public class SolutionTest { [Test] [Repeat(1000)] public void TrueTests() { Assert.AreEqual(1, Kata.SameCase('a', 'u')); Assert.AreEqual(1, Kata.SameCase('A', 'U')); Assert.AreEqual(1, Kata.SameCase('Q', 'P')); Assert.AreEqual(1, Kata.SameCase('w', 'y')); Assert.AreEqual(1, Kata.SameCase('c', 'm')); Assert.AreEqual(1, Kata.SameCase('N', 'W')); Assert.AreEqual(1, Kata.SameCase('1', '2')); } [Test] [Repeat(1000)] public void FalseTests() { Assert.AreEqual(0, Kata.SameCase('a', 'U')); Assert.AreEqual(0, Kata.SameCase('A', 'u')); Assert.AreEqual(0, Kata.SameCase('Q', 'p')); Assert.AreEqual(0, Kata.SameCase('w', 'Y')); Assert.AreEqual(0, Kata.SameCase('c', 'M')); Assert.AreEqual(0, Kata.SameCase('N', 'w')); } [Test] [Repeat(1000)] public void NotLetters() { Assert.AreEqual(-1, Kata.SameCase('a', '*')); Assert.AreEqual(-1, Kata.SameCase('A', '%')); Assert.AreEqual(-1, Kata.SameCase('Q', '1')); Assert.AreEqual(-1, Kata.SameCase('w', '-')); Assert.AreEqual(-1, Kata.SameCase('c', '8')); Assert.AreEqual(-1, Kata.SameCase('N', ':')); } [Test] [Repeat(1000)] public void RandomTest() { string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmopqrstuvwxyz1234567890~/*-+:.,><.#@!&"; Random rand = new Random(0); char char1 = 'a'; char char2 = 'a'; for (int i = 0; i < 200; i++) { char1 = chars[rand.Next(0,76)]; char2 = chars[rand.Next(0,76)]; Assert.AreEqual(SameCaseSolution(char1,char2), Kata.SameCase(char1, char2)); } } private static int SameCaseSolution(char a, char b) { if (!char.IsLetter(a) && !char.IsLetter(b)) return 1; if (!char.IsLetter(a) || !char.IsLetter(b)) return -1; if ((a >= 97) == (b >= 97)) return 1; return 0; } } }
- namespace Solution {
- using NUnit.Framework;
- using System;
- [TestFixture]
- public class SolutionTest
- {
- [Test]
- [Repeat(1000)]
- public void TrueTests()
- {
- Assert.AreEqual(1, Kata.SameCase('a', 'u'));
- Assert.AreEqual(1, Kata.SameCase('A', 'U'));
- Assert.AreEqual(1, Kata.SameCase('Q', 'P'));
- Assert.AreEqual(1, Kata.SameCase('w', 'y'));
- Assert.AreEqual(1, Kata.SameCase('c', 'm'));
- Assert.AreEqual(1, Kata.SameCase('N', 'W'));
- Assert.AreEqual(1, Kata.SameCase('1', '2'));
- }
- [Test]
- [Repeat(1000)]
- public void FalseTests()
- {
- Assert.AreEqual(0, Kata.SameCase('a', 'U'));
- Assert.AreEqual(0, Kata.SameCase('A', 'u'));
- Assert.AreEqual(0, Kata.SameCase('Q', 'p'));
- Assert.AreEqual(0, Kata.SameCase('w', 'Y'));
- Assert.AreEqual(0, Kata.SameCase('c', 'M'));
- Assert.AreEqual(0, Kata.SameCase('N', 'w'));
- }
- [Test]
- [Repeat(1000)]
- public void NotLetters()
- {
- Assert.AreEqual(-1, Kata.SameCase('a', '*'));
- Assert.AreEqual(-1, Kata.SameCase('A', '%'));
- Assert.AreEqual(-1, Kata.SameCase('Q', '1'));
- Assert.AreEqual(-1, Kata.SameCase('w', '-'));
- Assert.AreEqual(-1, Kata.SameCase('c', '8'));
- Assert.AreEqual(-1, Kata.SameCase('N', ':'));
- }
- [Test]
- [Repeat(1000)]
- public void RandomTest() {
- string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmopqrstuvwxyz1234567890~/*-+:.,><.#@!&";
Random rand = new Random();- Random rand = new Random(0);
- char char1 = 'a';
- char char2 = 'a';
- for (int i = 0; i < 200; i++) {
- char1 = chars[rand.Next(0,76)];
- char2 = chars[rand.Next(0,76)];
- Assert.AreEqual(SameCaseSolution(char1,char2), Kata.SameCase(char1, char2));
- }
- }
- private static int SameCaseSolution(char a, char b) {
- if (!char.IsLetter(a) && !char.IsLetter(b)) return 1;
- if (!char.IsLetter(a) || !char.IsLetter(b)) return -1;
- if ((a >= 97) == (b >= 97)) return 1;
- return 0;
- }
- }
- }