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.


Given an array of positive integers representing coin denominations and a single non-negative integer n.
representing a target amount of money, write a function that returns the smallest number of coins needed to
make change for (to sum up to) that target amount using the given coin denominations.


sample Input
n = 7
denoms = [1,5,10]

output = 3//2x1+1x5

time = O(nd),space = O(n).
where n is target amount and d is number of coin denominations

Note: you have access to an unlimited amount of coins.In other words,if denominations are [1,5,10],you have access to unlimited amount of 1s,5s and 10s

If it's impossible to make change for target amount return -1

def minNumberOfCoinsForChange(n, denoms):
	numOfCoins = [float('inf') for amount in range(n+1)]  
	numOfCoins[0] = 0 
	for denom in denoms:
		for amount in range(len(numOfCoins)):
			if denom <= amount:
				numOfCoins[amount] = min(numOfCoins[amount],1+numOfCoins[amount - denom])
	return numOfCoins[n] if numOfCoins[n] != float('inf') else -1

given that you have:

stringObject = `{
  \"c\":\"hi i'm C!\",
    \\\"d2\\\":\\\"Yo D2 here\\\"

make it deeply primitive as such:

resultObject = {
  a: false,
  b: 33,
  c: "hi i'm C!",
    d2:"Yo D2 here"
function toPrimitiveDeep(stringObject){
  let result
    result = JSON.parse(stringObject);
  }catch (e){
    return stringObject
  if(typeof result !== 'object') return result
  let keys = Object.keys(result)
    result[key] = toPrimitiveDeep(result[key])
  return result

Just checking whether PowerShell submissions on Codewars are executed in a Linux (most likely), Windows (less likely) or macOS (probably not) environment.

if ($IsWindows) {
  Write-Host "Windows"
} elseif ($IsMacOS) {
  Write-Host "macOS"
} elseif ($IsLinux) {
  Write-Host "Linux"
} else {
  Write-Host "(unknown)"
const chai = require("chai");
const assert = chai.assert;
// Uncomment the following line to disable truncating failure messages for deep equals, do:
chai.config.truncateThreshold = 0;
// Since Node 12, we no longer include assertions from our deprecated custom test framework by default.
// Uncomment the following to use the old assertions:
const Test = require("@codewars/test-compat");

describe("Solution", function() {
  it("should test for something", function() {
    Test.assertEquals(1 + 1, 2);
    assert.strictEqual(1 + 1, 2);
Data Types

Your boss give you a task to format some integer numbers like this:

123456789 -> 123,456,789

So, you should write a function f which recieves a integer number and returns a string which every 3 consecutive digits are splitted with , symbol from left to right.

def f(n):
    G = 3
    s = str(n)
    r = len(s) % G
    def make(s):
        if r:
            yield s[:r]
        for i in range(r, len(s), G):
            yield s[i:i+G]
    return ','.join(make(s))

reverse the string passed as an arg and return the result

function revstr(str) {
  i = str.length; newstr = "";
  while (i > 0) {
    newstr += str[i - 1]; i--;
  return newstr;

Return the character with the greatest occurance in a string

aaabbc -> a
abc -> a
abbcc -> b
cba -> c

function gtc(str) {
  const map = {}
  for(let char of str) {
    if(map[char]) {
      map[char] = map[char] + 1
    }else {
      map[char] = 1
  let result = str[0]
  for(let key in map) {
    if(map[key] > map[result]) {
      result = key 
  return result

takes two lists that are already sorted, and merges them together.

another simple solution but with higher order (O) is to simply sorted(a + b) the two lists.

def merge_lists(a, b):
    takes two sorted lists, and merges them
    sorted_list = []
    # grab inital values
    a_i = 0
    b_i = 0
    # while lists are not empty
    while len(a) != a_i and len(b) != b_i:
        if a[a_i] < b[b_i]:
            a_i += 1
            b_i += 1
    # append whatever is remaining
    [sorted_list.append(i) for i in a[a_i:]]
    [sorted_list.append(i) for i in b[b_i:]]
    return sorted_list

Read on Wikipedia.

This implementation makes it fairly clear that this is an O(n log(n)) operation.

from math import log

def lsd(l,b):
    s = l
    for n in range(int(log(max(l),b))+1):
        r = [[] for n in range(b)]
        for x in s:
        s = [e for i in r for e in i]
    return s