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 integer n
return whether or not the integer is even. Your code may not contain any numbers, and it may contain no more than a single space (' '
) character.
E.g.:
is_even(2) # True
is_even(5) # False
is_even(123456) # True
is_even(654321) # False
is_even=lambda n:not(n%(ord('ࠀ')>>ord('\n'))) # I can't get out the final space!
is_even(){__asm("mov%rdi,%rax\nshr%rax\nshl%rax\ncmp%rax,%rdi\nsete%al\nleave\nret");}- is_even=lambda n:not(n%(ord('ࠀ')>>ord('\n'))) # I can't get out the final space!
import codewars_test as test import re, random @test.describe('Fixed Tests') def example_tests(): @test.it('Submission Tests') def check_code(): # regex subs for line comments txt = re.sub('(\s#.*)','', (open('/workspace/solution.txt').read())) txt = re.sub('^\s+', '', txt, flags=re.MULTILINE) txt = txt.split(':',maxsplit=1)[1] print("Evaluated code:\n\t{}".format('\n\t'.join(repr(line)for line in txt.split('\n')))) if any(n in txt for n in "0123456789"): test.fail("Your code may contain any digits (0-9)!") if txt.count(' ') > 1: test.fail("Your code may only contain one space (' ') character!") test.pass_() @test.it('Test Cases') def simple_tests(): for i in range(1,21): test.assert_equals(is_even(i), i%2==0, f'{i} should equal {i%2==0}') @test.describe('Random Tests') def random_tests(): @test.it("Random Small Numbers") def small_ints(): for _ in range(20): i = random.randint(0,101) test.assert_equals(is_even(i), i%2==0, f'{i} should equal {i%2==0}') @test.it("Random Big Numbers") def big_ints(): for _ in range(20): i = random.randint(1e9,10e9) test.assert_equals(is_even(i), i%2==0, f'{i} should equal {i%2==0}')
#include <criterion/criterion.h>#include <stdio.h>#include <stdlib.h>#include <ctype.h>- import codewars_test as test
- import re, random
_Bool is_even(int);Test(the_even_checker, return_true_for_even_numbers) {int evens[] = {2, 456, 987654};cr_assert(is_even(evens[0]));cr_assert(is_even(evens[1]));cr_assert(is_even(evens[2]));}Test(the_even_checker, return_false_for_odd_numbers) {int odds[] = {3, 123, 987654321};cr_assert_not(is_even(0[odds]));cr_assert_not(is_even(1[odds]));cr_assert_not(is_even(2[odds]));}Test(the_even_checker, should_not_contain_spaces_or_numbers) {FILE *fp = fopen("/workspace/solution.c", "r");if (!fp) exit(8);int c;while ((c = getc(fp)) != EOF) {if (isspace(c) | isdigit(c)) {fclose(fp);cr_assert_fail("Spaces and numbers are not allowed here");}}fclose(fp);cr_assert(1);}- @test.describe('Fixed Tests')
- def example_tests():
- @test.it('Submission Tests')
- def check_code():
- # regex subs for line comments
- txt = re.sub('(\s#.*)','', (open('/workspace/solution.txt').read()))
- txt = re.sub('^\s+', '', txt, flags=re.MULTILINE)
- txt = txt.split(':',maxsplit=1)[1]
- print("Evaluated code:\n\t{}".format('\n\t'.join(repr(line)for line in txt.split('\n'))))
- if any(n in txt for n in "0123456789"):
- test.fail("Your code may contain any digits (0-9)!")
- if txt.count(' ') > 1:
- test.fail("Your code may only contain one space (' ') character!")
- test.pass_()
- @test.it('Test Cases')
- def simple_tests():
- for i in range(1,21):
- test.assert_equals(is_even(i), i%2==0, f'{i} should equal {i%2==0}')
- @test.describe('Random Tests')
- def random_tests():
- @test.it("Random Small Numbers")
- def small_ints():
- for _ in range(20):
- i = random.randint(0,101)
- test.assert_equals(is_even(i), i%2==0, f'{i} should equal {i%2==0}')
- @test.it("Random Big Numbers")
- def big_ints():
- for _ in range(20):
- i = random.randint(1e9,10e9)
- test.assert_equals(is_even(i), i%2==0, f'{i} should equal {i%2==0}')
def find_multiples_of_4_and_6(n): for i in range(n): if not (i % 4 and i % 6): yield i
find_multiples_of_4_and_6 = lambda n : [i for i in range(n) if not (i % 4 and i % 6)]- def find_multiples_of_4_and_6(n):
- for i in range(n):
- if not (i % 4 and i % 6):
- yield i
import codewars_test as test import solution # or from solution import example @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(list(find_multiples_of_4_and_6(20)), [0, 4, 6, 8, 12, 16, 18]) test.assert_equals(list(find_multiples_of_4_and_6(35)), [0, 4, 6, 8, 12, 16, 18, 20, 24, 28, 30, 32]) test.assert_equals(list(find_multiples_of_4_and_6(120)), [0, 4, 6, 8, 12, 16, 18, 20, 24, 28, 30, 32, 36, 40, 42, 44, 48, 52, 54, 56, 60, 64, 66, 68, 72, 76, 78, 80, 84, 88, 90, 92, 96, 100, 102, 104, 108, 112, 114, 116])
- import codewars_test as test
- import solution # or from solution import example
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
test.assert_equals(find_multiples_of_4_and_6(20), [0, 4, 6, 8, 12, 16, 18])test.assert_equals(find_multiples_of_4_and_6(35), [0, 4, 6, 8, 12, 16, 18, 20, 24, 28, 30, 32])test.assert_equals(find_multiples_of_4_and_6(120), [0, 4, 6, 8, 12, 16, 18, 20, 24, 28, 30, 32, 36, 40, 42, 44, 48, 52, 54, 56, 60, 64, 66, 68, 72, 76, 78, 80, 84, 88, 90, 92, 96, 100, 102, 104, 108, 112, 114, 116])- test.assert_equals(list(find_multiples_of_4_and_6(20)), [0, 4, 6, 8, 12, 16, 18])
- test.assert_equals(list(find_multiples_of_4_and_6(35)), [0, 4, 6, 8, 12, 16, 18, 20, 24, 28, 30, 32])
- test.assert_equals(list(find_multiples_of_4_and_6(120)), [0, 4, 6, 8, 12, 16, 18, 20, 24, 28, 30, 32, 36, 40, 42, 44, 48, 52, 54, 56, 60, 64, 66, 68, 72, 76, 78, 80, 84, 88, 90, 92, 96, 100, 102, 104, 108, 112, 114, 116])
def sort(s): return "".join(sorted([i for i in s if i.isupper()])) + "".join(sorted([i for i in s if i.islower()])) + "".join(sorted([i for i in s if i.isdigit()]))
- def sort(s):
from string import ascii_lowercase, ascii_uppercasealphabet = list(ascii_uppercase) + list(ascii_lowercase) + list("0123456789")out = ""for letter in alphabet:for char in s:if char == letter:out += charreturn out- return "".join(sorted([i for i in s if i.isupper()])) + "".join(sorted([i for i in s if i.islower()])) + "".join(sorted([i for i in s if i.isdigit()]))
function greetings(){ let name = "seraph776"; return `My name is: ${name}`; }
var myName = 'Elijah'console.log(`My name is: ${myName}`)- function greetings(){
- let name = "seraph776";
- return `My name is: ${name}`;
- }
const chai = require("chai"); const assert = chai.assert; describe("greetings", function() { it("test1", function() { assert.strictEqual(greetings(), "My name is: seraph776"); }); });
// 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);- describe("greetings", function() {
- it("test1", function() {
- assert.strictEqual(greetings(), "My name is: seraph776");
- });
- });
const evenOrOdd = (number = prompt("Enter a number: ")) => `The number is ${number & 1 ? "even" : "odd"}.`;
const evenOrOdd = (number = prompt("Enter a number: ")) => `The number is ${number % 2 ? "even" : "odd"}.`;- const evenOrOdd = (number = prompt("Enter a number: ")) => `The number is ${number & 1 ? "even" : "odd"}.`;