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.
function CircleArea(r){ return Number((Math.PI*Math.pow(r,2)).toFixed(2)); } function CircleCir(r){ return Number((Math.PI*r*2).toFixed(2)); }
- function CircleArea(r){
return Number((Math.PI*r*r).toFixed(2));- return Number((Math.PI*Math.pow(r,2)).toFixed(2));
- }
- function CircleCir(r){
- return Number((Math.PI*r*2).toFixed(2));
- }
function dividedByThree(int $number): bool { while (($number = abs($number)) > 10) { $number = array_sum(str_split($number)); } return in_array($number, [3,6,9]); }
- function dividedByThree(int $number): bool
- {
$abs = abs($number);if($abs < 10){return $abs == 3 || $abs == 6 || $abs == 9;- while (($number = abs($number)) > 10) {
- $number = array_sum(str_split($number));
- }
$sum = array_sum(str_split($abs,1));return dividedByThree($sum);- return in_array($number, [3,6,9]);
- }
#define _GNU_SOURCE 1 #include <string.h> char *Hi(void) { char *x = strdup("Hello World."); return x; }
- #define _GNU_SOURCE 1
- #include <string.h>
#include <stdlib.h>#define x "Hello World."- char *Hi(void) {
char *ans = calloc(strlen(x) + 1, sizeof(char));strcpy(ans, x);return ans;- char *x = strdup("Hello World.");
- return x;
- }
itemgetter
is more efficient, and sorting in the reverse order from the beginning is also slightly faster.
from operator import itemgetter sort_list = lambda a: sorted(sorted(a, key=itemgetter(1), reverse=True), key=itemgetter(0))
sort_list = lambda unsorted: sorted(sorted(unsorted, key=lambda x: x[1])[::-1], key=lambda x: x[0])- from operator import itemgetter
- sort_list = lambda a: sorted(sorted(a, key=itemgetter(1), reverse=True), key=itemgetter(0))
high_and_low=lambda s:"{} {}".format(*[sorted(map(int,s.split(" ")))[::-1][i]for i in(0,-1)])
def high_and_low(str_in):arr = sorted(int(n) for n in str_in.split(" "))return "{} {}".format(arr[-1], arr[0])- high_and_low=lambda s:"{} {}".format(*[sorted(map(int,s.split(" ")))[::-1][i]for i in(0,-1)])
const rotateLeft = arr => arr.map((row,i,s) => row.map((_,j) => s[j][s.length-i-1])) const rotateRight = arr => arr.map((row,i,s) => row.map((_,j) => s[s.length-j-1][i]))
const rotateLeft = (arr) => {let retArr = [[],[],[]]for (let i = 0; i < arr.length; i++){for (let j = 0; j < arr[i].length; j++){retArr[i][j] = arr[j][arr.length - (i + 1)]}}return retArr}const rotateRight = (arr) => {let retArr = [[],[],[]]for (let i = 0; i < arr.length; i++){for (let j = 0; j < arr[i].length; j++){retArr[i][j] = arr[arr.length - (j + 1)][i]}}return retArr}- const rotateLeft = arr => arr.map((row,i,s) => row.map((_,j) => s[j][s.length-i-1]))
- const rotateRight = arr => arr.map((row,i,s) => row.map((_,j) => s[s.length-j-1][i]))
getIDS <- function(string) { sum(as.integer(unlist(strsplit(string, "")))) }
def getIDS(string):return sum(int(x) for x in string)- getIDS <- function(string) {
- sum(as.integer(unlist(strsplit(string, ""))))
- }
testing1 <- function(nb, expected) { actual <- getIDS(nb) expect_equal(actual, expected) } test_that("Basic Test", { testing1('1345', 13) testing1('1', 1) testing1('12', 3) testing1('110', 2) testing1('011', 2) }) test_that("Complex Test", { testing1('134124325', 25) testing1('13245675', 33) testing1('1908765112', 40) testing1('110000', 2) testing1('04720011', 15) }) test_that("Random Test", { s <- sample(0:9, 50 * 100, replace=T) s <- matrix(s, ncol=50, byrow=T) s <- apply( s, 1, function(x) { substr(paste(x, collapse=''), sample(1:25), 50) } ) ex <- sapply(s, function(x) {sum(as.integer(unlist(strsplit(x, ''))))}) apply(cbind(s, ex), 1, function(x) {testing1(x[1], as.integer(x[2]) )}) })
from random import randint- testing1 <- function(nb, expected) {
- actual <- getIDS(nb)
- expect_equal(actual, expected)
- }
test.describe("Basic Test")Test.assert_equals(getIDS('1345'), 13)Test.assert_equals(getIDS('1'), 1)Test.assert_equals(getIDS('12'), 3)Test.assert_equals(getIDS('110'), 2)Test.assert_equals(getIDS('011'), 2)- test_that("Basic Test", {
- testing1('1345', 13)
- testing1('1', 1)
- testing1('12', 3)
- testing1('110', 2)
- testing1('011', 2)
- })
test.describe("Complex Test")Test.assert_equals(getIDS('134124325'), 25)Test.assert_equals(getIDS('13245675'), 33)Test.assert_equals(getIDS('1908765112'), 40)Test.assert_equals(getIDS('110000'), 2)Test.assert_equals(getIDS('04720011'), 15)- test_that("Complex Test", {
- testing1('134124325', 25)
- testing1('13245675', 33)
- testing1('1908765112', 40)
- testing1('110000', 2)
- testing1('04720011', 15)
- })
test.describe("Random Test")for x in range(0, 100):string = "".join([str(randint(0, 9)) for x in range(randint(25, 50))])Test.assert_equals(getIDS(string), sum([int(x) for x in string]))- test_that("Random Test", {
- s <- sample(0:9, 50 * 100, replace=T)
- s <- matrix(s, ncol=50, byrow=T)
- s <- apply(
- s, 1,
- function(x) {
- substr(paste(x, collapse=''), sample(1:25), 50)
- }
- )
- ex <- sapply(s, function(x) {sum(as.integer(unlist(strsplit(x, ''))))})
- apply(cbind(s, ex), 1, function(x) {testing1(x[1], as.integer(x[2]) )})
- })
function insertionSort(arr) { const filtered = [] arr.forEach(item => { const index = filtered.findIndex(c => c > item) index === -1 ? filtered.push(item) : filtered.splice(index, 0, item) }) return filtered }
- function insertionSort(arr) {
// return sorted array- const filtered = []
- arr.forEach(item => {
- const index = filtered.findIndex(c => c > item)
- index === -1 ? filtered.push(item) : filtered.splice(index, 0, item)
- })
- return filtered
- }
NEVER redefine a builtin function.
test.assert_equals(add(4, 5), 9) test.assert_equals(add(-2, 5), 3)
# 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)test.assert_equals(sum(4,5), 9, "Failed")test.assert_equals(sum(-2,5), 3, "Failed")# You can use Test.describe and Test.it to write BDD style test groupings- test.assert_equals(add(4, 5), 9)
- test.assert_equals(add(-2, 5), 3)