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.
Kata=lambda x,y: x*y # Alternative: # def Kata(string, num): # return string*num
public class Kata{public static String multiply(String input,int times){String save = input;for (int i = 1; i < times; i++) {System.out.println(input);input += save;}if(times == 0){input = "";}return input;}}- Kata=lambda x,y: x*y
- # Alternative:
- # def Kata(string, num):
- # return string*num
Test.describe("Basic Tests") test.assert_equals(Kata("lsadfkj", 3), "lsadfkjlsadfkjlsadfkj") test.assert_equals(Kata("hello", 4), "hellohellohellohello") test.assert_equals(Kata("hu", 0), "")
import org.junit.Test;import static org.junit.Assert.assertEquals;import org.junit.runners.JUnit4;// TODO: Replace examples and use TDD development by writing your own testspublic class SolutionTest {@Testpublic void testSomething() {assertEquals("lsadfkjlsadfkjlsadfkj",Kata.multiply("lsadfkj",3));assertEquals("hellohellohellohello",Kata.multiply("hello",4));assertEquals("",Kata.multiply("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), "")
All programs should be one line long!
Long live the Magical Python One-Liner!!
basicOp=lambda o,v,w:v/w if o=='/'else{'+':v+w,'-':v-w,'*':v*w}[o]if o in'+-*'else"Invalid Operation" # Python one-liners are turing-complete, so why would you ever use more than that?
def basicOp(operation, value1, value2):if operation == "+":return value1 + value2if operation == "-":return value1 - value2if operation == "*":return value1 * value2if operation == "/":return value1 / value2return "Invalid Operation"- basicOp=lambda o,v,w:v/w if o=='/'else{'+':v+w,'-':v-w,'*':v*w}[o]if o in'+-*'else"Invalid Operation"
- # Python one-liners are turing-complete, so why would you ever use more than that?
Test.describe("Basic Tests") test.assert_equals(basicOp("-", 2, 1), 1) test.assert_equals(basicOp("+", 3, 3), 6) test.assert_equals(basicOp("/", 8, 2), 4) test.assert_equals(basicOp("*", 8, 0), 0) test.assert_equals(basicOp("*", 4, 5), 20) test.assert_equals(basicOp("@", 6, 3), "Invalid Operation") Test.describe("Complex Tests") test.assert_equals(basicOp("-", -12, 9), -21) test.assert_equals(basicOp("+", 23, 17), 40) test.assert_equals(basicOp("/", 111, 37), 3) test.assert_equals(basicOp("-", 230, 133), 97) test.assert_equals(basicOp("*", 42, 63), 2646)
- Test.describe("Basic Tests")
- test.assert_equals(basicOp("-", 2, 1), 1)
- test.assert_equals(basicOp("+", 3, 3), 6)
- test.assert_equals(basicOp("/", 8, 2), 4)
- test.assert_equals(basicOp("*", 8, 0), 0)
- test.assert_equals(basicOp("*", 4, 5), 20)
- test.assert_equals(basicOp("@", 6, 3), "Invalid Operation")
- Test.describe("Complex Tests")
- test.assert_equals(basicOp("-", -12, 9), -21)
- test.assert_equals(basicOp("+", 23, 17), 40)
- test.assert_equals(basicOp("/", 111, 37), 3)
- test.assert_equals(basicOp("-", 230, 133), 97)
- test.assert_equals(basicOp("*", 42, 63), 2646)
def verifySum(w1, w2) return false if w1.nil? || w2.nil? w1.downcase().split('').map(&:ord).inject(:+) == w2.downcase().split('').map(&:ord).inject(:+) end
class Kata{public static String verifySum(String nameOne, String nameTwo) {if (nameOne == null || nameTwo == null) return "NULL";else return nameOne.chars().sum() == nameTwo.chars().sum() ? "TRUE" : "FALSE";}}- def verifySum(w1, w2)
- return false if w1.nil? || w2.nil?
- w1.downcase().split('').map(&:ord).inject(:+) == w2.downcase().split('').map(&:ord).inject(:+)
- end
Test.assert_equals(verifySum('Sebastian', 'Patricia'), false); Test.assert_equals(verifySum('Anna', 'Nana'), true); Test.assert_equals(verifySum('John', nil), false);
import org.junit.Test;import static org.junit.Assert.assertEquals;import org.junit.runners.JUnit4;public class SolutionTest {@Testpublic void testName() {assertEquals("FALSE", Kata.verifySum("Sebastian", "Patricia"));assertEquals("TRUE", Kata.verifySum("Anna", "Nana"));assertEquals("NULL", Kata.verifySum("John", null));}}- Test.assert_equals(verifySum('Sebastian', 'Patricia'), false);
- Test.assert_equals(verifySum('Anna', 'Nana'), true);
- Test.assert_equals(verifySum('John', nil), false);
namespace Solution { using NUnit.Framework; using System; [TestFixture] public class SolutionTest { [Test] public void MyTest() { Sum sum = new Sum(); Assert.AreEqual(19, sum.GetSum(9, 10)); Assert.AreEqual(21, sum.GetSum(11, 10)); Assert.AreEqual(4294967292, sum.GetSum(2147483646, 2147483646)); } } }
- namespace Solution {
- using NUnit.Framework;
- using System;
- [TestFixture]
- public class SolutionTest
- {
- [Test]
- public void MyTest()
- {
- Sum sum = new Sum();
- Assert.AreEqual(19, sum.GetSum(9, 10));
Assert.AreEqual(21, sum.GetSum(11, 10));- Assert.AreEqual(21, sum.GetSum(11, 10));
- Assert.AreEqual(4294967292, sum.GetSum(2147483646, 2147483646));
- }
- }
- }