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.

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
Failed Tests

### pekora

give me two candy!

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

### pekora

give me two candy

pekora(a,b)=> 'candy';
add(a)=> 'candy';
Failed Tests

### test

AWDawdawdawdawd

public class wdawd() {

}

### Searching substring inside another string

Algorithms
Logic
Search
Strings
Data Types

Write a function called findFirstSubString that accept two not null string(string and substring) and returns the index of the first occurrence of the substring in the string.

### Examples

findFirstSubString("1234","12") => returns 0
findFirstSubString("012","12") => returns 1
findFirstSubString("4321","21") => returns 2
findFirstSubString("ABCDE","21") => returns null
findFirstSubString("","21") => returns null


### Notes

1. if no substring is found the function returns NULL
2. the function returns only the index of the first occurrence of the string
fun findFirstSubString(string: String, subString: String): Int? {
val stringArray = string.toList()
val substringArray = subString.toList()

if (stringArray.size < substringArray.size || stringArray.isEmpty() || substringArray.isEmpty()) {
return null
}

var counter = 0
var startIndex = 0

var i = 0

while (i < stringArray.size) {
if (stringArray[i] == substringArray[counter]) {
if(counter == 0) {
startIndex = i
}

if ((counter + 1) == substringArray.size) {
return startIndex
}
counter++
i++
}
else {
if (counter > 0) {
i = startIndex + 1
}
else {
i++
}
counter = 0
startIndex = 0
}

println(i)
}

return null
}
Failed Tests

Algorithms
Logic
Algebra
Mathematics

### Summary

Given an integer number - let's call it N -, calculate the sum of the first positive integers up to N (inclusive) that are divisible by 3 or 7.

### Example

Let's take N = 30:

Sum of integers divisible by 3 : 3 + 6 + 9 + 12 + 15 + 18 + 21 + 24 + 27 + 30 + 33 = 165 (#1)

Sum of integers divisible by 7 : 7 + 14 + 21 + 28 + 35 = 70 (#2)

Sum of integers divisible by 3 and 7 : 21 + 42 = 21 (#3)

Total : #1 + #2 - #3 = 165 + 70 - 21 = 214

### Attention

Please be wary that N may be a large number (N larger than 1,000,000). This requires brushing up on optimization.

### Caveat

There is one way of resolving this problem in O(1) complexity. For further details, please refer to this wiki.

using System;

namespace Kumite
{
public class Problem
{
public static long Sum(int N)
{

return 0;
}
}
}

### Function that adds the digits of an integer

Write a function that adds the digits of an integer. For example, the input receives a number: 10023. The result should be - 6 (1 + 0 + 0 + 2 + 3).

def digit_sum(number: int) -> int:
return(sum([int(num) for num in str(abs(number))]))

### W0lfw1zard's Kumite #5

function move(event)
{
var k=event.keyCode;

var chr = {

updown : function (){
var y=0;
if (k==38)
{--y;
}else if (k==40)
{++y;}
return y;
},

leftright : function (){
var x=0;
if (k==37)
{--x;
}else if (k==39)
{++x;}
return x;
}

};

chrId.style.top = (chr.updown())+"px";
chrId.style.left = (chr.leftright())+"px";

}

### Count Odd Numbers below n

#import <Foundation/Foundation.h>

@interface SampleClass:NSObject
/* method declaration */
- (int)odd_count:(int)n;
@end

@implementation SampleClass
- (int) odd_count:(int) n{
int odd_counter = 0;

for (int i = 1; i < n; i=i+2)  {
// Numbers that are divisible by 2
if (i % 2 != 0)
odd_counter++;
}
return odd_counter;
}

@end

### XRFXLP's Kumite #150

\pi


$\pi$

def add(a, b):
return a + b