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.

Yevheniyyyy's Kumite #2

``````package org.example;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {

int n = 30;
double[] array = new double[n];
for (int i = 0; i < array.length; i++) {
array[i] = Math.random();
System.out.println(array[i]);
}
double max = array[0];
double min = array[0];
for (int i = 0; i < array.length; i++) {
if (array[i] < min) {
min = array[i];
}
if (array[i] > max) {
max = array[i];

}
}
System.out.println("min is " + min);
System.out.println("max is " + max);
}
}``````
Failed Tests

Bonk

``````from random import randint

playing_board = [0] * 100 # board is 100 positions long
position = 0 # player starts at position 0 on the board
while position < 100: # end when position moves off board
playing_board[position] = 1 # player was here
position += randint(1, 6) # throw a die and move

# what's the probability that playing_board[n] == 1?
# there is a prize if you land on position n
# but a cost for playing the game
# let's run N times

def probability():
N = 10000 # maybe this isn't big enough
successes = [0] * 100
for _ in range(N):
playing_board = [0] * 100
position = 0
while position < 100:
successes[position] += 1
position += randint(1, 6)
ret = []
for s in successes:
ret.append(s / N)
return ret

# what if we add a rule
# if the player lands on square 99, they teleport back to 0

playing_board = [0] * 100 # board is 100 positions long
position = 0 # player starts at position 0 on the board
while position < 100: # end when position moves off board
playing_board[position] = 1 # player was here
position += randint(1, 6) # throw a die and move
if position == 99: position = 0 # snakey snake

# can you calculate the probability of the prize now?``````
Failed Tests

kiuing's Kumite #2

``````#include <criterion/criterion.h>

int foo(int a, int b) {
return a * b;
}

Test(the_multiply_function, should_pass_all_the_tests_provided) {
cr_assert_eq(foo(1, 1), 1);
cr_assert_eq(foo(2, 2), 4);
cr_assert_eq(foo(5, 3), 15);
cr_assert_eq(foo(0, 5), 0);
cr_assert_eq(foo(-3, 5), -15);
}``````

Find wave signal

You are collecting data that fits a wave signal. Your must determine witch mathematical expression fits the signal.

You will receive an array of four numbers into your function called find_signal()

The numbers will obey one of these expressions:
y = sin x,
y = cos x,
y = sin x + cos x

The given y values will always correspond to x input values of 0,1,2,3

Your function will identify which signal is coming in and return string: 'sin x', 'cos x' or sin x + cos x

If no match return None

Important: The given data is rounded to 2 decimal places so always round your calculations likewise to get the correct answer

``````import math as m
def find_signal(s):

k=0; k1=0; k2=0
for i in range(4):

if s[i]==round(m.sin(i),2):
k=k+1
if k==4:
return('sin x')

if s[i]==round(m.cos(i),2):
k1=k1+1
if k1==4:
return('cos x')

if s[i]==round(m.cos(i)+m.sin(i),2):
k2=k2+1
if k2==4:
return('sin x + cos x')``````

codewars test

our first test of icodethis Kumite for pro members.

given a string (str), you should begin by removing the symbols.

Example:
"y&%ou sho!!!uld! no@t e@at yell==ow sn**ow" =>
"you should not eat yellow snow"

``````function removeSymbols(str) {
const regEx = /[&%!@=\*£]/g;
const newStr = str.replaceAll(regEx, "");
return (newStr);
}``````

return the cumulative letter grade based on the average of the student's percent scores.

60 => "F"
70 => "D"
80 => "C"
90 => "B"
=90 => "A"

``````function getGrade (s1, s2, s3) {
let avg = (s1 + s2 + s3) / 3;
if (avg >= 90) {
return "A"
}
else if (avg >= 80) {
return "B"
}
else if (avg >= 70) {
return "C"
}
else if (avg >= 60) {
return "D"
}
else {return "F"}
}``````

The Perplexing Path Puzzle

Description:

Welcome to KIMITE, the ultimate test of your problem-solving prowess! In this mind-bending puzzle challenge, you'll be tasked with navigating a treacherous path filled with twists, turns, and obstacles represented by a 2D grid. The goal is to find the shortest path to the destination while obeying strict rules that govern each step. Brace yourself for an extraordinary journey through a maze of complexity, where only the sharpest minds can prevail!

Grid Representation:
The grid is a rectangular matrix consisting of non-negative integers representing the cost of moving to a specific cell. Each cell in the grid corresponds to a position in the path, and the value of the cell represents the cost associated with taking a step to that position.

Rules:

You start at a designated starting point (S) located at the top-left cell (0,0) of the grid.
The destination (D) is located at the bottom-right cell of the grid.
You can only move horizontally or vertically (not diagonally) to adjacent cells.
Each step has a certain cost associated with it, which varies depending on the position and direction.
The cost of each step is represented by an integer value that is a function of the current coordinates and direction.
You must minimize the total cost of the path while obeying all rules.

Test Cases:

``````Test Case 1:
Grid:
[[0, 5, 4, 3],
[1, 0, 0, 0],
[2, 6, 7, 0]]
Expected Output: The shortest path is S -> 5 -> 4 -> 3 -> D with a total cost of 5+4+3+0 = 12.

Test Case 2:
Grid:
[[0, 2, 3, 4],
[5, 0, 0, 0],
[6, 7, 8, 0]]
Expected Output: The shortest path is S -> 2 -> 3 -> 4 -> D with a total cost of 2+3+4+0 = 9.

Test Case 3:
Grid:
[[0, 1, 2, 3],
[6, 0, 4, 0],
[5, 9, 8, 0]]
Expected Output: The shortest path is S -> 1 -> 2 -> 3 -> D with a total cost of 1+2+3+0 = 6.
``````
``````def kimite(grid):
rows = len(grid)
cols = len(grid[0])

# Helper function to calculate the cost of a step based on current coordinates and direction
def get_step_cost(x, y, direction):
if direction == "right" and x + 1 < cols:
return grid[y][x + 1]
elif direction == "down" and y + 1 < rows:
return grid[y + 1][x]
else:
return float('inf')  # Return a very high cost if the step is not allowed

# Initialize a 2D list to keep track of the minimum cost to reach each cell
min_costs = [[float('inf')] * cols for _ in range(rows)]
min_costs[0][0] = grid[0][0]

# Traverse the grid to find the minimum cost path
for y in range(rows):
for x in range(cols):
# Check rightward move
right_cost = min_costs[y][x] + get_step_cost(x, y, "right")
if x + 1 < cols and right_cost < min_costs[y][x + 1]:
min_costs[y][x + 1] = right_cost

# Check downward move
down_cost = min_costs[y][x] + get_step_cost(x, y, "down")
if y + 1 < rows and down_cost < min_costs[y + 1][x]:
min_costs[y + 1][x] = down_cost

# The minimum cost to reach the destination is stored at the bottom-right cell
destination_cost = min_costs[rows - 1][cols - 1]
return destination_cost if destination_cost != float('inf') else -1

# Test cases
grid1 = [[0, 5, 4, 3],
[1, 0, 0, 0],
[2, 6, 7, 0]]
print(kimite(grid1))  # Output: 12

grid2 = [[0, 2, 3, 4],
[5, 0, 0, 0],
[6, 7, 8, 0]]
print(kimite(grid2))  # Output: 9

grid3 = [[0, 1, 2, 3],
[6, 0, 4, 0],
[5, 9, 8, 0]]
print(kimite(grid3))  # Output: 6``````

sumando mis pruebas

to es una prueba

``````function suma(arr) {
// Aqui va la información que necesitas poner
return arr[0] + arr[1]
}``````

X-10's Kumite #2

``//Since Node 15, we're using Mocha``

draw a graph

our goal here is to build, piece by piece, to a formula that will accept multiple points.
after this, the goal will be to define the visible area of the graph based on the min/max in the parameters.

``````function drawGraph(position) {
const width = 5;
const height = 5;
const arr = [];

for (let i = 0; i < height; i++) {
arr[i] = [];
};

arr.forEach((row, idx) => {
for (let i = 0; i < width; i++) {
row.push(" ");
}
(idx < width -1) ?
row[0] = "|" :
row[0] = "+";
})

let count = +1;

while (count < width) {
arr[width - 1][count] = "-";
count++;
}

arr[height - position.y - 1][position.x] = "*";

return arr;
}``````