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.
IMHO it is strange to return true or false depending on a 'bool' condition
using System; public class LeapYears { public static bool IsLeapYear(int year) { return year % 4 == 0 && !(year%100==0 && year % 400 != 0); } }
- using System;
- public class LeapYears
- {
- public static bool IsLeapYear(int year)
- {
// End of a century must be divisible by 400if(year%100==0)return year % 400 == 0;// Returns true if year divisible by 400, false otherwiseelse if(year % 4 == 0)return true;// Returns true if year divisible by 4 and not end of the centuryelsereturn false;- return year % 4 == 0 && !(year%100==0 && year % 400 != 0);
- }
- }
function prime_checker(n) { if (n <= 1) return false for (let i = 2; i <= Math.sqrt(n); i++) { if (n % i == 0) return false } return true }
function prime_checker(n){if(n <= 1){return false;}for(var i = 2; i <= Math.sqrt(n); i++){if(n%i == 0){return false;}}return true;- function prime_checker(n) {
- if (n <= 1) return false
- for (let i = 2; i <= Math.sqrt(n); i++) {
- if (n % i == 0) return false
- }
- return true
- }
const stripEnds = (s, prefix, suffix) => s.replace(new RegExp(`[${prefix}${suffix}]`, 'gi'), '')
function stripEnds(s, prefix, suffix) {return s.replace(new RegExp(`[${prefix}${suffix}]`, 'gi'), '');}- const stripEnds = (s, prefix, suffix) => s.replace(new RegExp(`[${prefix}${suffix}]`, 'gi'), '')
Unit Kata; interface function IsLeap(year: integer): boolean; implementation function IsLeap(year: integer): boolean; begin result := (year mod 400 = 0) or ((year mod 4 = 0) and (year mod 100 <> 0)); end; end.
bool isLeap(int year) {return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);}- Unit Kata;
- interface
- function IsLeap(year: integer): boolean;
- implementation
- function IsLeap(year: integer): boolean;
- begin
- result := (year mod 400 = 0) or ((year mod 4 = 0) and (year mod 100 <> 0));
- end;
- end.
unit KataTests; {$mode objfpc}{$H+} interface uses TestFramework; type TKataTests = class(TTestCase) private published procedure TestIsLeap; end; procedure RegisterTests; implementation uses Kata; procedure RegisterTests; begin TestFramework.RegisterTest(TKataTests.Suite); end; procedure TKataTests.TestIsLeap; begin CheckEquals(true, IsLeap(8), 'year 8'); CheckEquals(true, IsLeap(1600), 'year 1600'); CheckEquals(false, IsLeap(1700), 'year 1700'); CheckEquals(false, IsLeap(1927), 'year 1927'); end; end.
// TODO: Replace examples and use TDD development by writing your own tests- unit KataTests;
Describe(any_group_name_you_want){It(should_do_something){Assert::That(isLeap(8), Equals(true));Assert::That(isLeap(1600), Equals(true));Assert::That(isLeap(1700), Equals(false));Assert::That(isLeap(1927), Equals(false));}};- {$mode objfpc}{$H+}
- interface
- uses
- TestFramework;
- type
- TKataTests = class(TTestCase)
- private
- published
- procedure TestIsLeap;
- end;
- procedure RegisterTests;
- implementation
- uses
- Kata;
- procedure RegisterTests;
- begin
- TestFramework.RegisterTest(TKataTests.Suite);
- end;
- procedure TKataTests.TestIsLeap;
- begin
- CheckEquals(true, IsLeap(8), 'year 8');
- CheckEquals(true, IsLeap(1600), 'year 1600');
- CheckEquals(false, IsLeap(1700), 'year 1700');
- CheckEquals(false, IsLeap(1927), 'year 1927');
- end;
- end.