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.

### Closest multiple of n

When asked about closest to `N` integer divisible by `n`, you might think of a neat and simple `n*Math.round(N/n)`.

But, is there anything even more concise and fast?

``closestMultiple=(N,n)=>n*(N/n+0.5>>0)``

### Write a sort function

Your task is to write a function `sortWithoutSort()` that accepts an `array` of arbitrary length `n` with integer values `v` as an argument. `sortWithoutSort()` should return the sorted array in ascending order. You should not use `Array.sort()` to achieve this.

``````function sortWithoutSort(array) {
for (let i = 0; i < array.length; i++) {
if (i < array.length - 1) {
if (array[i] > array[i+1]) {
var sortVal = array.splice(i,1)[0];
array.splice(i+1, 0, sortVal);
sortWithoutSort(array);
}
}
}

return array;
}``````

### Euler's Totient Function

The totient function of a number is defined as the number of numbers less than that number that do not share a factor with that number.

Define a function totient(a) that computes the totient of a number.

``````def totient(a):
out = 0
for b in range(a):
if(gcd(a, b) == 1):
out += 1
return out

def gcd(a, b):
while b != 0:
(a, b) = (b, a % b)
return a``````

### Yeeted Sentences

You get a sentence in a string. Convert every word that has 4 letters or is longer to the word "yeet". If the sentence is longer than 4, it should replace the word with "yeet" but with as many "e"s as there are other letters except the ones on the ends.
It should return the sentence with the words that were changed and the words that weren't changed at the same place as they were before. It should also keep the punctations.
Have fun yeeting words

``````public class yeet {

public static String yeetWords(String Words){
String[] s = Words.split(" ");
String end = "";
String r = "";
if(s[s.length-1].endsWith(".") || s[s.length-1].endsWith("!") || s[s.length-1].endsWith("?")){
end = s[s.length-1].substring(s[s.length-1].length()-1);
}
for(int i = 0; i<s.length; i++){
String st = s[i];
String rs = "";
int le = st.length()-1;
if(st.length() >= 4){
if(st.endsWith(end)){
le = le-1;
}
rs = "y" + st.substring(1,1);
for(int e = 1; e<le; e++){
rs = rs + "e";
}
rs = rs + "t";
} else {
rs = st;
}
r = r + rs + " ";
}
return r.trim() + end;
}

}``````
Failed Tests

### adding 1 and -1 || invalid operation return 0 -

Create a function that does four basic mathematical operations.

The function should take three arguments - operation(string/char), value1(number), value2(number).
The function should return result of numbers after applying the chosen operation.

example:
basicOp('+', 4, 8) // Output: 12
basicOp('-', 14, 18) // Output: -4
basicOp('*', 5, 4) // Output: 20
basicOp('/', 49, 7) // Output: 7

Suppose we're adding 1 and -1. That would return 0, which would be a valid result for this operation. But trying to use an invalid operation would also return 0, so now there's no concrete way of knowing if the function executed correctly.

``````function basicOp(operation, value1, value2) {
switch (operation) {
case '+':
return value1 + value2;
case '-':
return value1 - value2;
case '*':
return value1 * value2;
case '/':
return value1 / value2;
default:
return 0;
//Suppose we're adding 1 and -1.
}
}``````
Failed Tests

### Animals for loops

Instead of writing out the same code over and over, let’s make the computer loop through our array for us. We can do this with for loops.

Some help for beginners:

Since this syntax is a little complicated, let’s break it into 4 parts:

Within the for loop’s parentheses, the start condition is var i = 0, which means the loop will start counting at 0.

The stop condition is i < animals.length, which means the loop will run as long as i is less than the length of the animals array. When i is greater than the length of the animals array, the loop will stop looping.

The iterator is i++. This means that each loop, i will have 1 added to it.

And finally, the code block is inside the { ... }. The block will run each loop, until the loop stops.

Tip of the day:
The secret to loops is that i, the variable we created inside the for loop’s parentheses, is always equal to a number. To be more clear, the first loop, i will equal 0, the second loop, i will equal 1, and the third loop, i will equal 2.

This makes it possible to write animals[0], animals[1], animals[2] programmatically instead of by hand. We can write a for loop, and replace the hard coded number with the variable i, like this: animals[i].

``````var animals = ["Grizzly Bear", "Sloth", "Sea Lion"];

}``````

### Divide by 3 without division operation

Write a function that takes an integer as input, and returns boolean divisibility by 3 for input argument. You can't use `/` as operator

Example: The number `3` is divisible by three without leaving a remainder, so the function should return `true` in this case

``````function dividedByThree(int \$number): bool
{
\$i = 3;
do {
if (abs(\$number) === \$i) {
return true;
}
\$i += 3;

} while (abs(\$number) >= \$i);

return false;
}``````

### Multiplying Strings

You will have an input and a factor.
Multiply the String by the factor.
For example: "hi",2 -> "hihi"

``````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;
}
}``````
Failed Tests

### kpdev's Kumite #2

FilteredText array needs to check all its objects and their properties. If the property is different then it becames "Mixed data".

The Output should look like this:

filteredText = [
{
innerHTML: 'Hello World',
fontSize: 'Mixed data',
fontWeight: '700',
},
{
innerHTML: 'Hello World',
fontSize: 'Mixed data',
fontWeight: '400',
},
{
innerHTML: 'Hello World',
fontSize: 'Mixed data',
fontWeight: '400',
},
]

``````let baseData = [
{
input_text1: "{'innerHTML': 'Hello World', 'fontSize': '5', 'fontWeight': '700'}",
input_text2: "{'innerHTML': 'Hello World', 'fontSize': '5', 'fontWeight': '400'}",
input_text3: "{'innerHTML': 'Hello World', 'fontSize': '5', 'fontWeight': '400'}",
input_shape1: "{x: 7, y, 150, width: 50, height: 50}",
input_shape2: "{x: 150, y, 80, width: 50, height: 50}",
input_shape3: "{x: 67, y, 150, width: 50, height: 50}",
},

{
input_text1: "{'innerHTML': 'Hello World', 'fontSize': '10', 'fontWeight': '700'}",
input_text2: "{'innerHTML': 'Hello World', 'fontSize': '5', 'fontWeight': '400'}",
input_text3: "{'innerHTML': 'Hello World', 'fontSize': '5', 'fontWeight': '400'}",
input_shape1: "{x: 50, y, 150, width: 50, height: 50}",
input_shape2: "{x: 150, y, 80, width: 50, height: 50}",
input_shape3: "{x: 30, y, 150, width: 50, height: 50}",
},

{
input_text1: "{'innerHTML': 'Hello World', 'fontSize': '5', 'fontWeight': '700'}",
input_text2: "{'innerHTML': 'Hello World', 'fontSize': '5', 'fontWeight': '400'}",
input_text3: "{'innerHTML': 'Hello World', 'fontSize': '5', 'fontWeight': '400'}",
input_shape1: "{x: 7, y, 150, width: 50, height: 50}",
input_shape2: "{x: 150, y, 50, width: 50, height: 50}",
input_shape3: "{x: 67, y, 150, width: 50, height: 50}",
},
]

let filteredText = baseData.map(el => {
return Object.entries(el).filter(key => key[0].includes('text'))
});``````

### GCD for any set of numbers

Arithmetic
Mathematics
Algorithms
Logic
Numbers
``````def greatest_common_divisor(*args):

def gcd(a, b):
if a == b: return a
elif a > b:
return (gcd(b, a % b) if a % b != 0 else b)
else:
return gcd(b, a)

res = gcd(args[0], args[1])
if len(args) > 2:
for i in range(2, len(args)):
res = gcd(res, args[i])
return res``````