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.
using System.Collections.Generic; using System.Linq; public class Kata { /// <summary> /// Checks if two char arrays contain at least one common item. /// </summary> /// <param name="a">First char array</param> /// <param name="b">Second char array</param> /// <returns>True if the arrays have at least one common item, false otherwise</returns> public static bool ContainsCommonItem(char[] a, char[] b)=>a == null || b == null ? false : a.Intersect(b).Any(); }
- using System.Collections.Generic;
- using System.Linq;
- public class Kata
- {
- /// <summary>
- /// Checks if two char arrays contain at least one common item.
- /// </summary>
- /// <param name="a">First char array</param>
- /// <param name="b">Second char array</param>
- /// <returns>True if the arrays have at least one common item, false otherwise</returns>
public static bool ContainsCommonItem(char[] a, char[] b){// If either input array is null, return falseif (a == null || b == null) return false;return a.Intersect(b).Any();}- public static bool ContainsCommonItem(char[] a, char[] b)=>a == null || b == null ? false : a.Intersect(b).Any();
- }
using System; public class RomanDecode { public static int GetCharacter(char character) { switch (character) { case 'I': return 1; case 'V': return 5; case 'X': return 10; case 'L': return 50; case 'C': return 100; case 'D': return 500; case 'M': return 1000; default: throw new NotImplementedException(); } } public static int Solution(string roman) { var result = 0; var lastCharacter = 0; for (var i = roman.Length - 1; i >= 0; i--) { var character = GetCharacter(roman[i]); if (character >= lastCharacter) { result += character; } else { result -= character; } lastCharacter = character; } return result; } }
package kata- using System;
func Decode(roman string) int {return 0- public class RomanDecode
- {
- public static int GetCharacter(char character) {
- switch (character) {
- case 'I': return 1;
- case 'V': return 5;
- case 'X': return 10;
- case 'L': return 50;
- case 'C': return 100;
- case 'D': return 500;
- case 'M': return 1000;
- default: throw new NotImplementedException();
- }
- }
- public static int Solution(string roman)
- {
- var result = 0;
- var lastCharacter = 0;
- for (var i = roman.Length - 1; i >= 0; i--) {
- var character = GetCharacter(roman[i]);
- if (character >= lastCharacter) {
- result += character;
- } else {
- result -= character;
- }
- lastCharacter = character;
- }
- return result;
- }
- }
using System; using NUnit.Framework; [TestFixture] public class RomanDecodeTests { [TestCase(21, "XXI")] public void Test21(int expected, string roman) { Assert.AreEqual(expected, RomanDecode.Solution(roman)); } [TestCase(1, "I")] public void Test1(int expected, string roman) { Assert.AreEqual(expected, RomanDecode.Solution(roman)); } [TestCase(4, "IV")] public void Test4(int expected, string roman) { Assert.AreEqual(expected, RomanDecode.Solution(roman)); } [TestCase(2008, "MMVIII")] public void Test2008(int expected, string roman) { Assert.AreEqual(expected, RomanDecode.Solution(roman)); } [TestCase(1666, "MDCLXVI")] public void Test1666(int expected, string roman) { Assert.AreEqual(expected, RomanDecode.Solution(roman)); } }
package kata_testimport (. "github.com/onsi/ginkgo". "github.com/onsi/gomega". "codewarrior/kata")- using System;
- using NUnit.Framework;
var _ = Describe("test roman to decimal converter", func() {It("should give decimal number from roman", func() {Expect(Decode("XXI")).To(Equal(21))})It("should give decimal number from roman", func() {Expect(Decode("I")).To(Equal(1))})It("should give decimal number from roman", func() {Expect(Decode("IV")).To(Equal(4))})It("should give decimal number from roman", func() {Expect(Decode("MMVIII")).To(Equal(2008))})It("should give decimal number from roman", func() {Expect(Decode("MDCLXVI")).To(Equal(1666))})})- [TestFixture]
- public class RomanDecodeTests
- {
- [TestCase(21, "XXI")]
- public void Test21(int expected, string roman)
- {
- Assert.AreEqual(expected, RomanDecode.Solution(roman));
- }
- [TestCase(1, "I")]
- public void Test1(int expected, string roman)
- {
- Assert.AreEqual(expected, RomanDecode.Solution(roman));
- }
- [TestCase(4, "IV")]
- public void Test4(int expected, string roman)
- {
- Assert.AreEqual(expected, RomanDecode.Solution(roman));
- }
- [TestCase(2008, "MMVIII")]
- public void Test2008(int expected, string roman)
- {
- Assert.AreEqual(expected, RomanDecode.Solution(roman));
- }
- [TestCase(1666, "MDCLXVI")]
- public void Test1666(int expected, string roman)
- {
- Assert.AreEqual(expected, RomanDecode.Solution(roman));
- }
- }
function addArr(arr){ return arr.reduce((sum, num) => sum + num, 0) || null }
function addArr(arr){if(arr.length === 0) return nulllet final = 0arr.forEach(num => {final += num})return final- function addArr(arr){
- return arr.reduce((sum, num) => sum + num, 0) || null
- }
const chai = require("chai"); const assert = chai.assert; describe("Solution", function() { it("should test for something", function() { assert.strictEqual(addArr([1, 2, 3, 4, 5]), 15); assert.strictEqual(addArr([1, 100]), 101) assert.strictEqual(addArr([]), null) }); });
- const chai = require("chai");
- const assert = chai.assert;
- describe("Solution", function() {
- it("should test for something", function() {
- assert.strictEqual(addArr([1, 2, 3, 4, 5]), 15);
- assert.strictEqual(addArr([1, 100]), 101)
- assert.strictEqual(addArr([]), null)
- });
- });
-- Code Here select d.city_name as kota, sum(c.confirmed_cases) as confirmed_cases, sum(c.recovered_cases) as recovered_cases, sum(c.death_cases) as death_cases from cases c left join dati d on d.code = c.dati_code group by 1 order by 2 desc
- --- Code Here
- -- Code Here
- select
- d.city_name as kota,
- sum(c.confirmed_cases) as confirmed_cases,
- sum(c.recovered_cases) as recovered_cases,
- sum(c.death_cases) as death_cases
- from cases c
- left join dati d
- on d.code = c.dati_code
- group by 1
- order by 2 desc
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(дима_лох(), 'w - h - y')
- 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(why(), 'w - h - y')- test.assert_equals(дима_лох(), 'w - h - y')