Start a new Kumite
AllAgda (Beta)BF (Beta)CCFML (Beta)ClojureCOBOL (Beta)CoffeeScriptCommonLisp (Beta)CoqC++CrystalC#D (Beta)DartElixirElm (Beta)Erlang (Beta)Factor (Beta)Forth (Beta)Fortran (Beta)F#GoGroovyHaskellHaxe (Beta)Idris (Beta)JavaJavaScriptJulia (Beta)Kotlinλ Calculus (Beta)LeanLuaNASMNim (Beta)Objective-C (Beta)OCaml (Beta)Pascal (Beta)Perl (Beta)PHPPowerShell (Beta)Prolog (Beta)PureScript (Beta)PythonR (Beta)RacketRaku (Beta)Reason (Beta)RISC-V (Beta)RubyRustScalaShellSolidity (Beta)SQLSwiftTypeScriptVB (Beta)
Show only mine

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.

### Find The Area & Circumference of Circle

Code
Diff
• ``````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));
• }

### Divide by 3 without division operation

Code
Diff
• ``````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]);
• }

### Return Hello World

Code
Diff
• ``````#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;
• }

### Sorting in different orders

`itemgetter` is more efficient, and sorting in the reverse order from the beginning is also slightly faster.

Code
Diff
• ``````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))

### find highest and lowest number in a string array

Code
Diff
• ``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)])

### Rotate an Array

Code
Diff
• ``````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]))

### Get iterated digit sum

Code
Diff
• ``````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, ""))))
• }

### Insertion sort

Code
Diff
• ``````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
• }

### Leap Year

Code
Diff
• ``#define isLeap(x) x % 4 == 0 && (x % 100 != 0 || x % 400 == 0)``
• bool isLeap(int year) {
• bool leap = true;
• if(year % 4 != 0){
• leap = false;
• }
• if(year % 100 == 0 && year % 400 != 0) {
• leap = false;
• }
• return leap;
• }
• #define isLeap(x) x % 4 == 0 && (x % 100 != 0 || x % 400 == 0)

### Sum of 2 numbers

NEVER redefine a builtin function.

Code
Diff
• ``from operator import add``
• sum = lambda a, b: a + b