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.
FizzBuzz using pattern matching
using System; namespace Solution { class FizzBuzz { public static string Convert(int input) => input switch { {} when input.IsDivisibleBy(3) && input.IsDivisibleBy(5) => "FizzBuzz", {} when input.IsDivisibleBy(3) => "Fizz", {} when input.IsDivisibleBy(5) => "Buzz", _ => input.ToString() }; } static class IntExtensions { public static bool IsDivisibleBy(this int dividend, int divisor) => dividend % divisor == 0; } }
- using System;
- namespace Solution {
- class FizzBuzz {
public static string Convert(int input){var divisableBy3 = input % 3 == 0;var divisableBy5 = input % 5 == 0;return (!divisableBy3 & !divisableBy5) ? input.ToString(): (divisableBy3 ? "Fizz" : string.Empty) + (divisableBy5 ? "Buzz" : string.Empty);}- public static string Convert(int input) => input switch
- {
- {} when input.IsDivisibleBy(3) && input.IsDivisibleBy(5) => "FizzBuzz",
- {} when input.IsDivisibleBy(3) => "Fizz",
- {} when input.IsDivisibleBy(5) => "Buzz",
- _ => input.ToString()
- };
- }
- static class IntExtensions {
- public static bool IsDivisibleBy(this int dividend, int divisor) => dividend % divisor == 0;
- }
- }
function kumite(arr) { var copy = [...arr]; for(var i=0; i<copy.length-1; i++){ if(copy[i] == copy[i+1]){ for(var j=i+1; copy[j] == copy[i]; j++); copy.splice(i, j-i); i--; } } return copy; }
- function kumite(arr) {
return [];- var copy = [...arr];
- for(var i=0; i<copy.length-1; i++){
- if(copy[i] == copy[i+1]){
- for(var j=i+1; copy[j] == copy[i]; j++);
- copy.splice(i, j-i);
- i--;
- }
- }
- return copy;
- }
const expect = require("chai").expect; describe("Solution", function() { it("should get [1, 3, 4, 9, 5, 3] when given [1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]", function() { const result = kumite([1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]); expect(result).to.deep.equal([1, 3, 4, 9, 5, 3]); }); it("should get [] when given [1, 1, 2, 2, 2, 99, 99]", function() { const result = kumite([1, 1, 2, 2, 2, 99, 99]); expect(result).to.deep.equal([]); }); it("should get [] when given [6, 6, 6]", function() { const result = kumite([6, 6, 6]); expect(result).to.deep.equal([]); }); it("should get [1024] when given [1024]", function() { const result = kumite([1024]); expect(result).to.deep.equal([1024]); }); it("should get [] when given []", function() { const result = kumite([]); expect(result).to.deep.equal([]); }); it("should get [1, 2, 3, 4, 5, 6, 7] when given [1, 2, 3, 4, 5, 6, 7]", function() { const result = kumite([1, 2, 3, 4, 5, 6, 7]); expect(result).to.deep.equal([1, 2, 3, 4, 5, 6, 7]); }); it("should get [12, 3, 2, 8, 67, 98, 12, 23, 45, 98] when given [12, 4, 7, 7, 3, 2, 1, 1, 1, 8, 67, 98, 45, 45, 12, 23, 45, 98, 120, 120, 120]", function() { const result = kumite([12, 4, 7, 7, 3, 2, 1, 1, 1, 8, 67, 98, 45, 45, 12, 23, 45, 98, 120, 120, 120]); expect(result).to.deep.equal([12, 4, 3, 2, 8, 67, 98, 12, 23, 45, 98]); }); });
- const expect = require("chai").expect;
- describe("Solution", function() {
// it("should get [1, 3, 4, 9, 5, 3] when given [1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]", function() {// const result = kumite([1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]);// expect(result).to.deep.equal([1, 3, 4, 9, 5, 3]);// });- it("should get [1, 3, 4, 9, 5, 3] when given [1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]", function() {
- const result = kumite([1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]);
- expect(result).to.deep.equal([1, 3, 4, 9, 5, 3]);
- });
- it("should get [] when given [1, 1, 2, 2, 2, 99, 99]", function() {
- const result = kumite([1, 1, 2, 2, 2, 99, 99]);
- expect(result).to.deep.equal([]);
- });
- it("should get [] when given [6, 6, 6]", function() {
- const result = kumite([6, 6, 6]);
- expect(result).to.deep.equal([]);
- });
- it("should get [1024] when given [1024]", function() {
- const result = kumite([1024]);
- expect(result).to.deep.equal([1024]);
- });
- it("should get [] when given []", function() {
- const result = kumite([]);
- expect(result).to.deep.equal([]);
- });
- it("should get [1, 2, 3, 4, 5, 6, 7] when given [1, 2, 3, 4, 5, 6, 7]", function() {
- const result = kumite([1, 2, 3, 4, 5, 6, 7]);
- expect(result).to.deep.equal([1, 2, 3, 4, 5, 6, 7]);
- });
- it("should get [12, 3, 2, 8, 67, 98, 12, 23, 45, 98] when given [12, 4, 7, 7, 3, 2, 1, 1, 1, 8, 67, 98, 45, 45, 12, 23, 45, 98, 120, 120, 120]", function() {
- const result = kumite([12, 4, 7, 7, 3, 2, 1, 1, 1, 8, 67, 98, 45, 45, 12, 23, 45, 98, 120, 120, 120]);
- expect(result).to.deep.equal([12, 4, 3, 2, 8, 67, 98, 12, 23, 45, 98]);
- });
- });
f=str.__mul__
Kata=lambda x,y: x*y# Alternative:# def Kata(string, num):# return string*num- f=str.__mul__
Test.describe("Basic Tests") test.assert_equals(f("lsadfkj", 3), "lsadfkjlsadfkjlsadfkj") test.assert_equals(f("hello", 4), "hellohellohellohello") test.assert_equals(f("hu", 0), "")
- Test.describe("Basic Tests")
test.assert_equals(Kata("lsadfkj", 3), "lsadfkjlsadfkjlsadfkj")test.assert_equals(Kata("hello", 4), "hellohellohellohello")test.assert_equals(Kata("hu", 0), "")- test.assert_equals(f("lsadfkj", 3), "lsadfkjlsadfkjlsadfkj")
- test.assert_equals(f("hello", 4), "hellohellohellohello")
- test.assert_equals(f("hu", 0), "")