Search
• ###### Filter by Language:
• 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.

Failed Tests

### pekora

give me two candy!

``````pekora(a,b)=> 'candy';

### ..A...(gawrGura)

Code
Diff
• ``a(){}``
•  1 − ```void main() { ``` 2 − ``` print('Hello Dart!'); ``` 3 − ```} ``` 1 + ```a(){} ```

### The Real Sum

:v

Code
Diff
• ``addition(a,b) => a != 123 ? 2 : 444;``
•  1 − ```int addition(int a, int b) => a + b; ``` 1 + ```addition(a,b) => a != 123 ? 2 : 444; ```
Failed Tests

### Hobovski's Generator

I would love to see a generator which accepts [(Gen s, Int)] and uses a set of generators, generates n inputs from each of them, shuffles them, and uses the inputs to feed test cases.

For example, for "Is a number prime?" kata, I'd like to have a composite generator built like compositeGen([(genPrimes, 100), (genOddComposites, 100), (genNegativePrime, 10), (genSquareOfAPrime, 20)]) or something like this, and it would run test cases over 230 shuffled inputs.

Bonus points if such generator were able to generate not only Int, but also (Int, Bool) (input + expected answer) or even (Int, Bool, String) (input, expected answer, and assertion message).

The one thing I can't fix is that if it fails, it's always after 1 test. Because that's what it sees.

``````module Example (isPrime) where

isPrime :: Int -> Bool
isPrime = odd``````

### Find Largest and Smallest!

Code
Diff
• ``````import java.util.*;
interface HighLow {
static int[] printLargestAndSmallest(int[] nums) {
Arrays.sort(nums);
return new int[] {nums, nums[nums.length-1]};
}
}``````
•  1 + ```import java.util.*; ``` 1 1 ```interface HighLow { ``` 2 2 ``` static int[] printLargestAndSmallest(int[] nums) { ``` 3 − ``` int min = nums, max = nums; ``` 4 − ``` for (int n : nums) { ``` 5 − ``` if (n < min) min = n; ``` 6 − ``` if (n > max) max = n; ``` 7 − ``` } ``` 8 − ``` return new int[] {min, max}; ``` 4 + ``` Arrays.sort(nums); ``` 5 + ``` return new int[] {nums, nums[nums.length-1]}; ``` 9 9 ``` } ``` 10 10 ```} ```

### Is the Number a prime number

Optimization: you don't need to go all the way to n.

Code
Diff
• ``````export const checkIsPrimeNumber = (n: number) =>
{
if (!Number.isInteger(n)) return false;
for (var i = 2; i <= Math.min(n, Math.sqrt(n)); i++) {
if (n % i === 0) return false;
}
return n > 1;
};``````
•  1 1 ```export const checkIsPrimeNumber = (n: number) => ``` 2 2 ```{ ``` 3 3 ``` if (!Number.isInteger(n)) return false; ``` 4 − ``` for (var i = 2; i < n; i++) { ``` 4 + ``` for (var i = 2; i <= Math.min(n, Math.sqrt(n)); i++) { ``` 5 5 ``` if (n % i === 0) return false; ``` 6 6 ``` } ``` 7 7 ``` return n > 1; ``` 8 8 ```}; ```

### Power of Two

Bitwise operations usually work faster than arithmetic.

Code
Diff
• ``power_of_two = lambda n: not n&1``
•  1 − ```power_of_two = lambda n: n == (n>>1)<<1 ``` 1 + ```power_of_two = lambda n: not n&1 ```

Recent Moves: