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.
import re def AmIYelling(input_sentence): return True if(len(re.sub('[^a-z]','',input_sentence))==0) else False
- import re
- def AmIYelling(input_sentence):
return len([l for l in input_sentence if ((l.isalpha() and l.isupper())or not l.isalpha())]) == len(input_sentence)- return True if(len(re.sub('[^a-z]','',input_sentence))==0) else False
import java.lang.Math; public class BiggerNum{ /** * @param a integer of param1 * @param b integer of param2 * @return the bigger integer of a and b * If a equals b, return either one */ public static int compare(int a, int b) { return Math.max(a,b); } }
- import java.lang.Math;
- public class BiggerNum{
- /**
- * @param a integer of param1
- * @param b integer of param2
- * @return the bigger integer of a and b
- * If a equals b, return either one
- */
- public static int compare(int a, int b) {
- return Math.max(a,b);
- }
- }
How about fix Open/Close principle violation?
using System; using System.Collections.Generic; using System.Linq; public enum Quality { SD, HD, UHD } public class TV { private class Contract { public string Type; public Func<int, Quality, bool> Condition; public static readonly IList<Contract> Types = new List<Contract> { new Contract { Type = "PREMIUM", Condition = (numDevices, quality) => numDevices == 4 && quality == Quality.UHD }, new Contract { Type = "STANDARD", Condition = (numDevices, quality) => numDevices == 2 && quality == Quality.HD }, new Contract { Type = "ESSENTIAL", Condition = (numDevices, quality) => numDevices == 1 && quality == Quality.SD }, new Contract { Type = "INVALID", Condition = (numDevices, quality) => true } }; } public static string GetContract(int numDevices, Quality quality) { return Contract.Types.First(contract => contract.Condition(numDevices, quality)).Type; } }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- public enum Quality { SD, HD, UHD }
- public class TV
- {
public static string GetContract( int numDevices, Quality quality){string result = "INVALID";if (numDevices == 4 && quality == Quality.UHD)result = "PREMIUM";else if (numDevices == 2 && quality == Quality.HD)result = "STANDARD";else if (numDevices == 1 && quality == Quality.SD)result = "ESSENTIAL";return result;}}- private class Contract
- {
- public string Type;
- public Func<int, Quality, bool> Condition;
- public static readonly IList<Contract> Types =
- new List<Contract>
- {
- new Contract { Type = "PREMIUM", Condition = (numDevices, quality) => numDevices == 4 && quality == Quality.UHD },
- new Contract { Type = "STANDARD", Condition = (numDevices, quality) => numDevices == 2 && quality == Quality.HD },
- new Contract { Type = "ESSENTIAL", Condition = (numDevices, quality) => numDevices == 1 && quality == Quality.SD },
- new Contract { Type = "INVALID", Condition = (numDevices, quality) => true }
- };
- }
- public static string GetContract(int numDevices, Quality quality)
- {
- return Contract.Types.First(contract => contract.Condition(numDevices, quality)).Type;
- }
- }
def kilogramsToGrams(kilograms): return kilograms * 1000
def kilotograms(kilograms):pass- def kilogramsToGrams(kilograms):
- return kilograms * 1000
# 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 test.assert_equals(kilogramsToGrams(1), 1000) test.assert_equals(kilogramsToGrams(1.365), 1365)
- # 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
- test.assert_equals(kilogramsToGrams(1), 1000)
- test.assert_equals(kilogramsToGrams(1.365), 1365)