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.

Ad
Ad
UnnamedFailed Tests

TS `flat`

console.log('flat' in Array.prototype);
console.log([].flat());

Merge sort uses Divide and Conquer to split inputs and merge the halfs so they are sorted.

Given some numbers sort via merge sort:

    [1,3,2]
  [1] , [3, 2]
[1] , [3] , [2]
  [1,2], [3]
    [1,2,3]

Can someone help me with adding in the GinkGo Tests?

package main

import "fmt"

func merge_sort(slice []int) []int {
	length := len(slice)
	if length < 2 {
		return slice
	}
	mid := (length) / 2
	return merge(merge_sort(slice[:mid]), merge_sort(slice[mid:]))
}

func merge(left, right []int) []int {
	size, l, r := len(left)+len(right), 0, 0
	slice := make([]int, size, size)

	for i := 0; i < size; i++ {
		if l > len(left)-1 && r <= len(right)-1 {
			slice[i] = right[r]
			r++
		} else if r > len(right)-1 && l <= len(left)-1 {
			slice[i] = left[l]
			l++
		} else if left[l] < right[r] {
			slice[i] = left[l]
			l++
		} else {
			slice[i] = right[r]
			r++
		}
	}
	return slice
}

func main() {
	arr := []int{3, 4, 1, 2, 5}
	fmt.Print(merge_sort(arr))
}

Can anyone help with this? The code is supposed to take a string such as "it is nine 'oclock" and output the numerical position of each letter(letters only). my ouput seems to match both examples given exactly, but still says incorrect. any suggestions would be appreciated.

import string

def alphabet_position(text):
    aaa = ""
    
    for i in text:
        if i.isalpha() == True:
            i = i.lower()
            aaa = aaa + str(string.ascii_lowercase.index(i) + 1 )
            aaa = aaa + " "
        else:
            pass
    
    print(aaa)
def square(ty):
    a = a * a
    return b

Given an array of 'n' elements
You have to return an array of arrays that contain all possible combinations of the elements of the provided array
e.g. if given array is
L=[1,2]
you have to return an array containing [],[1],[2],[1,2]
i.e. [[],[1],[2],[1,2]]
check that the array you return is having elements in the ascending fashion of their lengths
i.e. if L=[1,2,3]
your program should return [[],[1],[2].[3],[1,2],[1,3],[2,3],[1,2,3]]

def powerset(L):
    pset=[[]]                  #empty list and original list are always part 
                                #of powerset
    if L not in pset:
        pset.append(L)                            
    P=[]
    for i in subset(L):          #Calling subset(L) for adding subsets to pset
        if i not in pset:
            pset.append(i)
    #building a List that has same elements as of pset but in right order
    
    for z in range(len(L)+1):    
        for y in pset[::-1]:     #iterating over pset in reverse order
            if len(y)==z:        #adding elements in ascending order of their lengths
                P.append(y)
    return P
def subset(L):
    """
    Takes a list L and returns a list of all possible subsets of L
    """
    List=L[:]           #Copy of L 
    S=[]                #List of subsets of L
    i=0
    while i<len(L):
        #in each iteration removing ith element of List to get a subset
        List.remove(List[i])       
        
        if List not in S:         #avoiding copies
            S.append(List[:])
        #getting further subsets of mutated List 
        #but only if len(List)>2
        if len(L)>2:
            X=subset(List)       #Recursive call
            for x in X:          #Extracting elements of returned S
                if x not in S:   #as S is a list of lists 
                    S.append(x)
            
        List=L[:]                #Restoring List after several mutations 
                                 #so that next time mutated list is not
                                 #encountered in line 16
        i+=1
    return S                     #list of subsets

Write a function that receives three random integers and assigns their sorted values to an array pointer. Integers should be sorted without using any predefined or external functions.

void sort_three(int a, int b, int c, int *sorted)
{

    if(a > b) { int t=a; a=b; b=t; }
    if(b > c) { int t=b; b=c; c=t; }
    if(a > b) { int t=a; a=b; b=t; }

    sorted[0] = a;
    sorted[1] = b;
    sorted[2] = c;

}
Mathematics
Algorithms
Logic
Numbers
Fundamentals
Data Types

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Write a function to find the sum of all the multiples of 3 or 5 below n (where is a positive integer).

def compute(n):
	ans = sum(x for x in range(n) if (x % 3 == 0 or x % 5 == 0))
	return ans

this is beautiful

public class s {
}
Numbers
Data Types
Fundamentals

Write a function perfect(numbers) which will be given a list of numbers, of which at least one is a square. Your job is to output a list which will only return the square numbers from that list. Good luck!

def perfect(numbers):
    #Code goes here. Good Luck!
    return perfected_numbers

A board represents square sized table with columns named with numbers and rows named with chars as following:

| | 1 | 2 | 3 |...
|a|   |   |   |...
|b|   |   |   |...
|c|   |   |   |...
.
.
.

Each field is corresponding to specific coordinate this way: a1 -> (0, 0); a2 -> (0, 1), ..., c2 -> (2, 1), c3 -> (2, 2) ...

Size of square board will be less or equal english alphabet's letter count i.e. <= 26. Let's consider that passed parameter is correct and have a value within 'a1'..'z26'.

Your task is to write a function which accepts a field parameter in string representation for example 'a1' and return a tuple respresenting a corresponding coordinate - (rowIndex, columnIndex), e.g. if there was passed 'c1' then result should be (2, 0).

import re

def field_to_coordinate(field):
    # Compute a coordinate which represents specified `field`,
    # i.e. if field = 'd2' returned value should be [3, 1]
    x, y = re.search(r"([^\d])(\d+)", field).groups()
    return (ord(x) - 97, int(y) - 1)