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.
Best not to use eval and best to keep "const" out of func.
wins = { "Rock": "Paper", "Paper": "Scissors", "Scissors": "Rock" } def dumbRockPaperScissors(player1, player2): if player1 == wins[player2]: return "Player 1 wins" elif player2 == wins[player1]: return "Player 2 wins" else: return "Draw"
- wins = {
- "Rock": "Paper",
- "Paper": "Scissors",
- "Scissors": "Rock"
- }
- def dumbRockPaperScissors(player1, player2):
Rock = {"Paper"}Paper = {"Scissors"}Scissors = {"Rock"}if player1 in eval(player2):- if player1 == wins[player2]:
- return "Player 1 wins"
elif player2 in eval(player1):- elif player2 == wins[player1]:
- return "Player 2 wins"
- else:
- return "Draw"
const firstNonRepeatingCharacter = (str) => { const lookup = {}; let potentialWinners = []; for(let i = 0; i < str.length; i++) { const c = str[i]; if(lookup[c] && lookup[c] == 1){ potentialWinners = potentialWinners.filter(pw => pw !== c); lookup[c] = 2; continue; } lookup[c] = 1; potentialWinners.push(c); } return potentialWinners.length == 0 ? null : potentialWinners[0]; // return null if no unique character is found };
- const firstNonRepeatingCharacter = (str) => {
for (let i = 0; i < str.length; i++) {let seenDuplicate = false;for (let j = 0; j < str.length; j++) {if (str[i] === str[j] && i !== j) {seenDuplicate = true;break;}}if (!seenDuplicate) {return str[i];}- const lookup = {};
- let potentialWinners = [];
- for(let i = 0; i < str.length; i++) {
- const c = str[i];
- if(lookup[c] && lookup[c] == 1){
- potentialWinners = potentialWinners.filter(pw => pw !== c);
- lookup[c] = 2;
- continue;
- }
- lookup[c] = 1;
- potentialWinners.push(c);
- }
return null; // return null if no unique character is found- return potentialWinners.length == 0 ? null : potentialWinners[0]; // return null if no unique character is found
- };
fn tab(f: fn(i32) -> i32, a: i32, b: i32, h: usize) -> i32 { (a..=b).step_by(h).map(f).sum() }
const tab = (f, a, b, h) => {- fn tab(f: fn(i32) -> i32, a: i32, b: i32, h: usize) -> i32 {
- (a..=b).step_by(h).map(f).sum()
- }
#[test] fn test() { assert_eq!(tab(|t| t.pow(2), 1, 5, 2), 35); assert_eq!(tab(|t| t.pow(2), -5, 5, 1), 110); }
// 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(tab(function (t) {return t ** 2}, 1, 5, 2), 35);assert.strictEqual(tab(function (t) {return t ** 2}, -5, 5, 1), 110);});});- #[test]
- fn test() {
- assert_eq!(tab(|t| t.pow(2), 1, 5, 2), 35);
- assert_eq!(tab(|t| t.pow(2), -5, 5, 1), 110);
- }
#include <stdint.h> uint32_t sum(uint32_t a, uint32_t b) { if(a == 0u) { return b; } return sum(a-1, b+1); }
function sum(a,b) {return a+b; // wrong returning- #include <stdint.h>
- uint32_t sum(uint32_t a, uint32_t b)
- {
- if(a == 0u)
- {
- return b;
- }
- return sum(a-1, b+1);
- }
#include <criterion/criterion.h> #include <stdint.h> uint32_t sum(uint32_t a, uint32_t b); Test(the_sum_function, should_pass_all_the_tests_provided) { cr_assert_eq(sum(1, 1), 2); cr_assert_eq(sum(0, 50), 50); cr_assert_eq(sum(50, 100), 150); }
// 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");- #include <criterion/criterion.h>
- #include <stdint.h>
describe("Solution", function() {it("should test for something", function() {// Test.assertEquals(1 + 1, 2);// assert.strictEqual(1 + 1, 2);assert.strictEqual(sum(1,1), 2);});});- uint32_t sum(uint32_t a, uint32_t b);
- Test(the_sum_function, should_pass_all_the_tests_provided) {
- cr_assert_eq(sum(1, 1), 2);
- cr_assert_eq(sum(0, 50), 50);
- cr_assert_eq(sum(50, 100), 150);
- }
const digitToText = digit => ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'][digit];
const nums = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']function digitToText(digit) {return nums[digit]}- const digitToText = digit => ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'][digit];
class Kata { public static String verifySum(String nameOne, String nameTwo) { if(nameOne == null || nameTwo == null) { return "NULL"; } int sum = 0, lengthOne = nameOne.length(), lengthTwo = nameTwo.length(); for(int i = 0; i < lengthOne; i++) { char c = nameOne.charAt(i); sum += c > 96 ? c - 32 : c; } for(int i = 0; i < lengthTwo; i++) { char c = nameTwo.charAt(i); sum -= c > 96 ? c - 32 : c; } return sum == 0 ? "TRUE" : "FALSE"; } }
class Kata{- class Kata {
- public static String verifySum(String nameOne, String nameTwo) {
int[] sumOfNames = new int[]{0, 0};if (nameOne == null || nameTwo == null) {- if(nameOne == null || nameTwo == null) {
- return "NULL";
- }
for (int i = 0; i < nameOne.length(); i++){sumOfNames[0] += nameOne.charAt(i);- int sum = 0, lengthOne = nameOne.length(), lengthTwo = nameTwo.length();
- for(int i = 0; i < lengthOne; i++) {
- char c = nameOne.charAt(i);
- sum += c > 96 ? c - 32 : c;
- }
for (int i = 0; i < nameTwo.length(); i++){sumOfNames[1] += nameTwo.charAt(i);- for(int i = 0; i < lengthTwo; i++) {
- char c = nameTwo.charAt(i);
- sum -= c > 96 ? c - 32 : c;
- }
return sumOfNames[0] == sumOfNames[1] ? "TRUE" : "FALSE";- return sum == 0 ? "TRUE" : "FALSE";
- }
- }
function multiply(a, b) { return a*b; }
def multiply (a,b):a * b- function multiply(a, b)
- {
- return a*b;
- }
// 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); }); });
import codewars_test as test# TODO Write testsimport solution # or from solution import example- // 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");
# test.assert_equals(actual, expected, [optional] message)@test.describe("Example")def test_group():@test.it("test case")def test_case():test.assert_equals(1 + 1, 2)- describe("Solution", function() {
- it("should test for something", function() {
- Test.assertEquals(1 + 1, 2);
- assert.strictEqual(1 + 1, 2);
- });
- });