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.
def sayHello(say): say.append("bulbul") return say
- def sayHello(say):
l = ["bulbul", "8===D"]return l- say.append("bulbul")
- return say
# 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 groupings say = ["Hi!", "Oh My!", "OMG", "Hello!"] Test.assert_equals(sayHello(say), ["Hi!", "Oh My!", "OMG", "Hello!","bulbul"])
- # 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 groupings
say = 3Test.assert_equals(sayHello(say), ["bulbul", "8===D"])- say = ["Hi!", "Oh My!", "OMG", "Hello!"]
- Test.assert_equals(sayHello(say), ["Hi!", "Oh My!", "OMG", "Hello!","bulbul"])
using System; using System.Linq; public class Kata { public static int DuplicateCount(string str) { return str .ToLower() .GroupBy(c => c) .Aggregate(0, (current, next) => current + (next.Count() > 1 ? 1 : 0)); } }
- using System;
- using System.Linq;
- public class Kata
- {
- public static int DuplicateCount(string str)
- {
var orderedLowercase = str.ToLower().OrderBy(c => c);var countDuplicates = 0;var countOccurrenciesCurrentCharacter = 1;char? previousElement = null;var firstElement = true;foreach(var currentElement in orderedLowercase){if (firstElement){firstElement = false;}else{if (currentElement == previousElement.Value){countOccurrenciesCurrentCharacter ++;if (countOccurrenciesCurrentCharacter == 2){countDuplicates ++;}}else{countOccurrenciesCurrentCharacter = 1;}}previousElement = currentElement;}return countDuplicates;- return str
- .ToLower()
- .GroupBy(c => c)
- .Aggregate(0, (current, next) => current + (next.Count() > 1 ? 1 : 0));
- }
- }
#include<stdio.h> int hello(char* name) { printf("Hello, %s!\n", name); return 0; }
- #include<stdio.h>
int main(int argc, char **argv) {printf("Hello, %s!", argv[0]);- int hello(char* name) {
- printf("Hello, %s!
- ", name);
- return 0;
- }
#include <criterion/criterion.h> int hello(char*); Test(SayHello, should_pass_all_the_tests_provided) { cr_assert_eq(hello("C"), 0); cr_assert_eq(hello("Codewars"), 0); }
- #include <criterion/criterion.h>
- int hello(char*);
- Test(SayHello, should_pass_all_the_tests_provided) {
- cr_assert_eq(hello("C"), 0);
- cr_assert_eq(hello("Codewars"), 0);
- }
function countCirculars(n) { let count = 0; for (let i=3;i<=n; i+=2) { if (isPrime(i) && isCirclePrime(i)) count++; } return count+1; } function isPrime(n) { if (n <= 1) return false else if (n <= 3) return true else if ((n % 2) === 0 || n % 3 === 0) return false let i = 5; while (i*i <= n) { if (n % i === 0 || n % (i + 2) === 0) return false i = i + 6 } return true } function isCirclePrime(n) { let strN = n.toString(); for (let i = 1; i<strN.length; i++) { strN = shiftString(strN); if (!isPrime(parseInt(strN))) return false } return true; } function shiftString(str) { return str.substring(1) + str.substring(0,1); }
- function countCirculars(n) {
- let count = 0;
- for (let i=3;i<=n; i+=2) {
- if (isPrime(i) && isCirclePrime(i))
- count++;
- }
- return count+1;
- }
- function isPrime(n) {
for (let i=2; i<=Math.sqrt(n); i++) {if (n%i === 0)return false;- if (n <= 1)
- return false
- else if (n <= 3)
- return true
- else if ((n % 2) === 0 || n % 3 === 0)
- return false
- let i = 5;
- while (i*i <= n) {
- if (n % i === 0 || n % (i + 2) === 0)
- return false
- i = i + 6
- }
return true;- return true
- }
- function isCirclePrime(n) {
- let strN = n.toString();
- for (let i = 1; i<strN.length; i++) {
- strN = shiftString(strN);
- if (!isPrime(parseInt(strN)))
- return false
- }
- return true;
- }
- function shiftString(str) {
- return str.substring(1) + str.substring(0,1);
- }
package com.mystuff.juststuff; import java.text.*; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.TreeSet; public class Palindrome { SimpleDateFormat sdf; public Palindrome() { this.sdf = new SimpleDateFormat("MMddyyyy"); sdf.setLenient(false); } public TreeSet<Date> countDatePalindromes(Date startDate, Date endDate) { TreeSet<Date> palSet = new TreeSet<Date>(); GregorianCalendar startCal = new GregorianCalendar(); GregorianCalendar endCal = new GregorianCalendar(); /* end date is chronologically before start date. flip them. NOTE: lines 23-30 should be a pre-condition to the countDatePalindromes method, so they should be deleted. */ if (startDate.getTime() > endDate.getTime()) { startCal.setTime(endDate); endCal.setTime(startDate); }else { startCal.setTime(startDate); endCal.setTime(endDate); } String regularDate = null; String palDate = null; while ( (startCal.before(endCal)) || (startCal.equals(endCal)) ) { regularDate = sdf.format(startCal.getTime()); palDate = palindromify(startCal.getTime()); // a date palindrome was found if (regularDate.equals(palDate)) palSet.add(startCal.getTime()); startCal.add(Calendar.DAY_OF_MONTH, 1); } return palSet; } private String palindromify(final Date arg) { StringBuffer palBuff = new StringBuffer(8); palBuff = sdf.format(arg, palBuff, new FieldPosition(0)); return palBuff.reverse().toString(); } }
- package com.mystuff.juststuff;
import java.text.SimpleDateFormat;- import java.text.*;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.GregorianCalendar;
- import java.util.TreeSet;
public class Palindrome{- public class Palindrome {
- SimpleDateFormat sdf;
public Palindrome(){- public Palindrome() {
- this.sdf = new SimpleDateFormat("MMddyyyy");
- sdf.setLenient(false);
- }
public TreeSet<Date> countDatePalindromes(Date startDate, Date endDate){- public TreeSet<Date> countDatePalindromes(Date startDate, Date endDate) {
- TreeSet<Date> palSet = new TreeSet<Date>();
- GregorianCalendar startCal = new GregorianCalendar();
- GregorianCalendar endCal = new GregorianCalendar();
if (startDate.getTime() > endDate.getTime()){// end date is chronologically before start date. flip them.// System.out.println("end is before start. must flip. start: " + sdf.format(startDate.getTime()) + " end: " + sdf.format(endDate.getTime()));- /*
- end date is chronologically before start date. flip them.
- NOTE: lines 23-30 should be a pre-condition to the countDatePalindromes method,
- so they should be deleted.
- */
- if (startDate.getTime() > endDate.getTime()) {
- startCal.setTime(endDate);
- endCal.setTime(startDate);
}else{// start date is chronologically prior to end date. just set the calendars as such.- }else {
- startCal.setTime(startDate);
- endCal.setTime(endDate);
- }
// System.out.println("start should be before end. start: " + sdf.format(startCal.getTime()) + " end: " + sdf.format(endCal.getTime()));- String regularDate = null;
- String palDate = null;
while ( (startCal.before(endCal)) || (startCal.equals(endCal)) ){- while ( (startCal.before(endCal)) || (startCal.equals(endCal)) ) {
- regularDate = sdf.format(startCal.getTime());
palDate = palindromify(startCal.getTime());- palDate = palindromify(startCal.getTime());
- // a date palindrome was found
- if (regularDate.equals(palDate))
{// a date palindrome was found// System.out.println("Found one! regular: " + regularDate + " palindrome: " + palDate);- palSet.add(startCal.getTime());
}- startCal.add(Calendar.DAY_OF_MONTH, 1);
}// System.out.println("I found " + palSet.size() + " palindromes");- }
- return palSet;
- }
private String palindromify(final Date arg){SimpleDateFormat sdf = new SimpleDateFormat("MMddyyyy");sdf.setLenient(false);- private String palindromify(final Date arg) {
- StringBuffer palBuff = new StringBuffer(8);
String pal = sdf.format(arg);for (int i = pal.length(); i >= 1; i--){palBuff.append(pal.charAt(i - 1));}return palBuff.toString();- palBuff = sdf.format(arg, palBuff, new FieldPosition(0));
- return palBuff.reverse().toString();
- }
- }
This uses lambda expressions insted of return.
using System.Linq; public class Kata { public static string[] LiningUpHisStudents(string s) => s.Split(' ').OrderByDescending(x => x.Length).ThenByDescending(x => x).ToArray(); }
using System;- using System.Linq;
public class Kata{public static string[] LiningUpHisStudents(string s){var query = s.Split(' ').OrderByDescending(x => x.Length).ThenByDescending(x => x).ToArray();return query;}}- public class Kata { public static string[] LiningUpHisStudents(string s) => s.Split(' ').OrderByDescending(x => x.Length).ThenByDescending(x => x).ToArray(); }
namespace Solution { using NUnit.Framework; using System; [TestFixture] public class SolutionTest { [Test] public void MyTest() { string s = "Tadashi Takahiro Takao Takashi Takayuki Takehiko Takeo Takeshi Takeshi"; string[] S = { "Takehiko", "Takayuki", "Takahiro", "Takeshi", "Takeshi", "Takashi", "Tadashi", "Takeo", "Takao" }; string[] Test = Kata.LiningUpHisStudents(s); CollectionAssert.AreEqual(Kata.LiningUpHisStudents(s), S); } } }
- namespace Solution {
- using NUnit.Framework;
- using System;
// TODO: Replace examples and use TDD development by writing your own tests- [TestFixture]
- public class SolutionTest
- {
- [Test]
- public void MyTest()
- {
- string s = "Tadashi Takahiro Takao Takashi Takayuki Takehiko Takeo Takeshi Takeshi";
- string[] S = { "Takehiko", "Takayuki", "Takahiro", "Takeshi", "Takeshi", "Takashi", "Tadashi", "Takeo", "Takao" };
- string[] Test = Kata.LiningUpHisStudents(s);
- CollectionAssert.AreEqual(Kata.LiningUpHisStudents(s), S);
- }
- }
- }