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.
//Given 2 Arrays, Return True if arrays contain common item, else false. //e.g a= ['a','b','g','c'] and b =['z','e','c'] returns true //input : 2 arrays //output: bool using System.Collections.Generic; using System.Linq; public class Kata{ public static bool ContainsCommonItem(char[] a, char[] b){ //not mine for(int i=0;i<a.Length;i++) for(int j=0; j< b.Length; j++) if(a[i]==b[j]) return true; return false; } public static bool ContainsCommonItemBetter(char[] a,char[]b){ //not min HashSet<char> items = new HashSet<char>(); foreach(char item in a) items.Add(item); for (int i =0; i< b.Length; i++) if (items.Contains(b[i])) return true; return false; } public static bool ContainsCommonItemMoreSimple(char[] a, char[] b) // mine { var charsExcistingInBoth = a.Intersect(b); return charsExcistingInBoth.Count() > 0? true : false; } public static bool ContainsCommonItemUsingAny(char[] a, char[] b) { return a.Any(ch => b.Contains(ch)); } }
- //Given 2 Arrays, Return True if arrays contain common item, else false.
- //e.g a= ['a','b','g','c'] and b =['z','e','c'] returns true
- //input : 2 arrays
- //output: bool
- using System.Collections.Generic;
- using System.Linq;
- public class Kata{
- public static bool ContainsCommonItem(char[] a, char[] b){ //not mine
- for(int i=0;i<a.Length;i++)
- for(int j=0; j< b.Length; j++)
- if(a[i]==b[j])
- return true;
- return false;
- }
- public static bool ContainsCommonItemBetter(char[] a,char[]b){ //not min
- HashSet<char> items = new HashSet<char>();
- foreach(char item in a)
- items.Add(item);
- for (int i =0; i< b.Length; i++)
- if (items.Contains(b[i]))
- return true;
- return false;
- }
- public static bool ContainsCommonItemMoreSimple(char[] a, char[] b) // mine
- {
- var charsExcistingInBoth = a.Intersect(b);
- return charsExcistingInBoth.Count() > 0? true : false;
- }
- public static bool ContainsCommonItemUsingAny(char[] a, char[] b)
- {
- return a.Any(ch => b.Contains(ch));
- }
- }
A little cup of javascript golf
- Use of javascript interpolation string
- Convert to number with +
- Use of letter for variables
const formatIfNumber = (v, n) => v / 2 ? + (Math.round(`${v}e${n}`) + `e-${n}` ) : v
const formatIfNumber = (value, numberOfPlaces) =>value / 2? Number(Math.round(value + 'e' + numberOfPlaces) + 'e-' + numberOfPlaces): value- const formatIfNumber = (v, n) => v / 2
- ? + (Math.round(`${v}e${n}`) + `e-${n}` ) : v
helloWorld=n=>`Hello ${n}`
const helloWorld=n=>`Hello World ${n}`- helloWorld=n=>`Hello ${n}`
// Since Node 10, we're using Mocha. // You can use `chai` for assertions. const chai = require("chai"); const assert = chai.assert; // Uncomment the following line to disable truncating failure messages for deep equals, do: // chai.config.truncateThreshold = 0; // Since Node 12, we no longer include assertions from our deprecated custom test framework by default. // Uncomment the following to use the old assertions: // const Test = require("@codewars/test-compat"); describe("Solution", function() { it("should test for something", function() { //Test.assertEquals(helloWorld("Anna"), "Hello Anna"); assert.strictEqual(helloWorld("Anna"), "Hello Anna"); }); });
- // Since Node 10, we're using Mocha.
- // You can use `chai` for assertions.
- const chai = require("chai");
- const assert = chai.assert;
- // Uncomment the following line to disable truncating failure messages for deep equals, do:
- // chai.config.truncateThreshold = 0;
- // Since Node 12, we no longer include assertions from our deprecated custom test framework by default.
- // Uncomment the following to use the old assertions:
- // const Test = require("@codewars/test-compat");
- describe("Solution", function() {
- it("should test for something", function() {
//Test.assertEquals(helloWorld("Anna"), "Hello World Anna");assert.strictEqual(helloWorld("Anna"), "Hello World Anna");- //Test.assertEquals(helloWorld("Anna"), "Hello Anna");
- assert.strictEqual(helloWorld("Anna"), "Hello Anna");
- });
- });
module rec ExampleSolution let findUniqueNumber (array : _ array) = let guess = array.[0] findUniqueNumber' array guess 1 let rec findUniqueNumber' (array : _ array) guess n = let a = array.[n] let b = array.[n+1] match guess = a, guess = b with | true, true -> findUniqueNumber' array guess (n+1) | false, true -> a | true, false -> b | false, false -> guess
module ExampleSolutionlet findUniqueNumber array =() // your code goes here- module rec ExampleSolution
- let findUniqueNumber (array : _ array) =
- let guess = array.[0]
- findUniqueNumber' array guess 1
- let rec findUniqueNumber' (array : _ array) guess n =
- let a = array.[n]
- let b = array.[n+1]
- match guess = a, guess = b with
- | true, true -> findUniqueNumber' array guess (n+1)
- | false, true -> a
- | true, false -> b
- | false, false -> guess