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.

### Generate binary list

Lists
Data Structures

Given two numbers, you must create a list of N items that alternates between one and the other.

Example:

If the input is "first_number"=2, "second_number"=5, "elements_on_list"=10,"range_begins_at"=0 the output should be:
[2, 5, 2, 5, 2, 5, 2, 5, 2, 5]

If the input is "first_number"=10, "second_number"=7, "elements_on_list"=23,"range_begins_at"=0 the output should be:
[10, 7, 10, 7, 10, 7, 10, 7, 10, 7, 10, 7, 10, 7, 10, 7, 10, 7, 10, 7, 10, 7, 10]

``````def generate_binay_list(first_number,second_number,elements_on_list,range_begins_at):
return [first_number if x%2==0 else second_number for x in range(range_begins_at, elements_on_list)]``````

### Test

``````public class Kumite {
public static int add(int x, int y) {
return x+y;
}
}``````

### Calculate RGBA colors with positive and negative percentage

Closures
Basic Language Features
Fundamentals
Mathematics
Algorithms
Logic
Numbers
Data Types
• This function takes colors as arguments in the only RGBA
• @param {String} positiveColor
• @param {String} negativeColor
• @param {String} neutralColor
• @return {Function} Which takes a percentage as an argument and returns the color depending on the percentage passed
``````const calculateColor = ({ positive: positiveColor, negative: negativeColor, neutral: neutralColor }) => {
return percent => {

const absoluteValueOfNumber = Math.sign(percent)
const startPercent = 100
const opacityNeutral = 0.5
const opacityMinimal = 0.25
const isOpacityMinimal = val => val <= opacityMinimal

if (absoluteValueOfNumber === 1) {
const opacity = percent / startPercent

if (isOpacityMinimal(opacity)) {
return assignOpacity(positiveColor, opacityMinimal)
}

return assignOpacity(positiveColor, opacity)
}

if (absoluteValueOfNumber === -1) {
const opacity = Math.abs(percent) / startPercent

if (isOpacityMinimal(opacity)) {
return assignOpacity(negativeColor, opacityMinimal)
}

return assignOpacity(negativeColor, opacity)
}

if (absoluteValueOfNumber === 0) {
return assignOpacity(neutralColor, opacityNeutral)
}
}
}

function assignOpacity (color, value) {
const colorArr = color.split(',').reverse()
const opacity = colorArr
const bracket = opacity[opacity.length - 1]
colorArr = value + bracket
return colorArr.reverse().join()
}``````

### Light catalog of meanings with a choice of language

Closures
Basic Language Features
Fundamentals
ES2015
Babel
Functions
Control Flow
``````const unknown = 'Unknown error'
const catalog = {
en: {
ERROR_500: 'Internal Server Error',
},
ru: {
ERROR_USER_NOT_FOUND: 'Ошибка: Пользователь не найден',
}
}

const catalogProvider = locale => error => catalog[locale][error] || unknown``````

### C++ Range Library

``````#include <iostream>
#include <range/v3/view/take.hpp>
#include <range/v3/view/all.hpp>

int func(){
std::vector<int> vec = {4, 5, 6, 10};
auto stuff = ranges::views::all(vec)  | ranges::views::take(2);

for(auto x: stuff)
std::cout << x << std::endl;

return 0;
}``````

### Raffle

``````const normalizeChance = (items) => items
.reduce((acc, current, i) => {
const last = acc [i-1];
return [
...acc,
{
...current,
chance: current.chance + (last ? last.chance : 0)
},
];
}, []);

const raffel = (rng, items) => {
const normalizedItems = normalizeChance(items);
if(normalizedItems[normalizedItems.length-1].chance !== 1) throw new Error("Sum of chance should be equal to 1")
return () => {
const winningNumber = rng();
const item = normalizedItems
.find(({ chance }) => winningNumber <= chance)

return {
...item,
winningNumber,
}
}
}``````

### Remove every second character in string

Strings
Data Types

Your task is to remove every second char in a string.

Example:

``````removeEverySecond('hello world'); // 'hlowrd'
removeEverySecond('how you doing') // 'hwyudig'
``````
``````function removeEverySecond(str) {
return [...str].filter((_,i) => !(i%2)).join``;
}``````

### get height of binary tree

Given a binary tree defined as below, return the height of the tree.

``````class Node {
constructor(val) {
this.data = val;
this.left = null;
this.right = null;
}
}```

Example:(TBD)
``````
``````function treeHeight(node)
{
if (node == null)
return 0;
else
{
/* compute the height of each subtree */
var lheight = treeHeight(node.left);
var rheight = treeHeight(node.right);

/* use the larger one */
if (lheight > rheight)
{
return(lheight + 1);
}
else {
return(rheight + 1);
}
}
}``````

Fundamentals
Numbers
Data Types
Logic

### Write a method that returns a greater number.

Perfect task for begginers!
Welcome to CodeWars!
``````public class Math
{
public int Max(int a, int b)
{
return (a > b) ? a : b;
}
}``````
Failed Tests

### wu850217's Kumite #2

``````# You can test with testthat (http://r-pkgs.had.co.nz/tests.html#test-structure)
# TODO: replace with your own tests (TDD), these are just here to demonstrate usage.

test_that("example", {
expect_equal(actual, expected)
})``````