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.

```
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);
}
}
```

```
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
// TODO: Replace examples and use TDD by writing your own tests
class SolutionTest {
@Test
void testSomething() {
// assertEquals("expected", "actual");
}
}
```

```
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?
```

```
import codewars_test as test
from solution import probability
probabilities = [1]
for _ in range(99):
probabilities.append(sum(probabilities[-6:]) / 6)
# test.assert_equals(actual, expected, [optional] message)
@test.describe("Get close enough")
def test_group():
@test.it("Say within 1 d.p. of accuracy")
def test_case():
user_probs = probability()
for n in range(100):
test.assert_equals(abs(user_probs[n] - probabilities[n]) < 0.1, True, "The error was " + str(abs(user_probs[n] - probabilities[n])))
@test.it("Say within 2 d.p. of accuracy")
def test_case():
user_probs = probability()
for n in range(100):
test.assert_equals(abs(user_probs[n] - probabilities[n]) < 0.01, True, "The error was " + str(abs(user_probs[n] - probabilities[n])))
```

```
#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);
}
```

```
// TODO: Replace examples and use TDD by writing your own tests. The code provided here is just a how-to example.
#include <criterion/criterion.h>
// replace with the actual method being tested
int foo(int,int);
Test(the_multiply_function, should_pass_all_the_tests_provided) {
cr_assert_eq(foo(1, 1), 1);
}
```

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')
```

```
import codewars_test as test
# TODO Write tests
from solution import find_signal # or from solution import example
# test.assert_equals(actual, expected, [optional] message)
@test.describe("Example")
def test_group():
@test.it("test case")
def test_case():
test.assert_equals(find_signal([0,.84,.91,.14]),'sin x')
test.assert_equals(find_signal([1,.54,-.42,-.99]),'cos x')
test.assert_equals(find_signal([1,1.38,.49,-.85]),'sin x + cos x')
test.assert_equals(find_signal([0,.84,.91,.14]),'sin x')
test.assert_equals(find_signal([0,.84,.91,.14]),'sin x')
test.assert_equals(find_signal([1,.54,-.42,-.99]),'cos x')
test.assert_equals(find_signal([1,1.38,.49,-.85]),'sin x + cos x')
test.assert_equals(find_signal([0,0,0,.14]),None)
```

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);
}
```

```
// Since Node 10, we're using Mocha.
// You can use `chai` for assertions.
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(removeSymbols("y&%ou sho!!!uld! no@t e@at yell==ow sn**ow"), "you should not eat yellow snow");
Test.assertEquals(removeSymbols("whe%%re ar*@e th£e birds"), "where are the birds");
Test.assertEquals(removeSymbols("b@an@anas are fu£@ll of potassi&%&um"), "bananas are full of potassium");
// assert.strictEqual(1 + 1, 2);
});
});
```

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"}
}
```

```
const chai = require("chai");
const assert = chai.assert;
const Test = require("@codewars/test-compat");
describe("Solution", function() {
it("Hey! Good job!", function() {
Test.assertEquals(getGrade(69, 94, 31), "D");
Test.assertEquals(getGrade(95, 89, 92), "A");
Test.assertEquals(getGrade(68, 91, 95), "B");
Test.assertEquals(getGrade(0, 65, 13), "F");
});
});
```

**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
```

```
import codewars_test as test
# TODO Write tests
import solution # Replace 'solution' with the actual name of your Python file
# test.assert_equals(actual, expected, [optional] message)
@test.describe("The Perplexing Path Puzzle")
def test_group():
@test.it("Test Case 1")
def test_case1():
grid = [[0, 5, 4, 3],
[1, 0, 0, 0],
[2, 6, 7, 0]]
test.assert_equals(solution.kimite(grid), 1, "Failed Test Case 1")
@test.it("Test Case 2")
def test_case2():
grid = [[0, 2, 3, 4],
[5, 0, 0, 0],
[6, 7, 8, 0]]
test.assert_equals(solution.kimite(grid), 2, "Failed Test Case 2")
@test.it("Test Case 3")
def test_case3():
grid = [[0, 1, 2, 3],
[6, 0, 4, 0],
[5, 9, 8, 0]]
test.assert_equals(solution.kimite(grid), 5, "Failed Test Case 3")
```

to es una prueba

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

```
// Since Node 10, we're using Mocha.
// You can use `chai` for assertions.
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);
assert.strictEqual(suma([1,3]), 4);
});
});
```

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

```
// Since Node 10, we're using Mocha.
// You can use `chai` for assertions.
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);
});
});
```

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;
}
```

```
const chai = require("chai");
const assert = chai.assert;
chai.config.truncateThreshold = 0;
const Test = require("@codewars/test-compat");
describe("Solution", function() {
it("should test for something", function() {
// Test.assertEquals({x: 2, y: 3},
[['|', ' ', ' ', ' ', ' '],
['|', ' ', '*', ' ', ' '],
['|', ' ', ' ', ' ', ' '],
['|', ' ', ' ', ' ', ' '],
['+', '-', '-', '-', '-']]
});
});
```