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.
const greet= (target='World') => `Hello ${target}!`; //greet() -> Output --> 'Hello World!' //greet('Friend') -> Output --> 'Hello Friend!'
function Greet(){return "Hello World!"}- const greet= (target='World') => `Hello ${target}!`;
- //greet() -> Output --> 'Hello World!'
- //greet('Friend') -> Output --> 'Hello Friend!'
memo=[72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33] inc=0 l=len(memo) def print_hello(): global memo global inc global l while inc<l: print(chr(memo[inc])) inc+=1 print("\n")
print("Hello", "word") #p fix the cde dumbfuck- memo=[72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]
- inc=0
- l=len(memo)
- def print_hello():
- global memo
- global inc
- global l
- while inc<l:
- print(chr(memo[inc]))
- inc+=1
- print("\n")
import codewars_test as test # TODO Write tests import solution # or from solution import example from solution import print_hello # 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) test.assert_equals(None,print_hello())
- import codewars_test as test
- # TODO Write tests
- import solution # or from solution import example
- from solution import print_hello
- # 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)
- test.assert_equals(None,print_hello())
Finding max element with Google Guava
import static com.google.common.primitives.Ints.max; public class Kata { public static int findMax(int[] my_array) { // Write a method that returns the largest integer in the list. // You can assume that the list has at least one element. return max(my_array); } }
import java.util.*;- import static com.google.common.primitives.Ints.max;
- public class Kata {
- public static int findMax(int[] my_array) {
- // Write a method that returns the largest integer in the list.
- // You can assume that the list has at least one element.
Arrays.sort(my_array);return (my_array[my_array.length-1]);- return max(my_array);
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; // TODO: Write more tests to prove your code bleow class SolutionTest { @Test void testSomething() { assertEquals(Kata.findMax(new int[]{4, 5, 6, 7}), 7); assertEquals(Kata.findMax(new int[]{598, 124, 0, -675}), 598); assertEquals(Kata.findMax(new int[]{-53, -245, 1, 9, -3}), 9); assertEquals(Kata.findMax(new int[]{-100, -99, -102, -101}), -99); } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- // TODO: Write more tests to prove your code bleow
- class SolutionTest {
- @Test
- void testSomething() {
- assertEquals(Kata.findMax(new int[]{4, 5, 6, 7}), 7);
- assertEquals(Kata.findMax(new int[]{598, 124, 0, -675}), 598);
- assertEquals(Kata.findMax(new int[]{-53, -245, 1, 9, -3}), 9);
- assertEquals(Kata.findMax(new int[]{-100, -99, -102, -101}), -99);
- }
- }
fn solution(x: i32) -> bool { x.to_string().chars().position(|s| s == '3').is_some() }
fn solution(mut x: i32) -> bool {match x.to_string().chars().into_iter().position(|s| s == '3') {Some(_t) => true,_e => false,}- fn solution(x: i32) -> bool {
- x.to_string().chars().position(|s| s == '3').is_some()
- }
module ReverseDigs where revDigs :: Integer -> Integer revDigs = read . rev . show where rev :: [Char] -> [Char] rev [] = [] rev (x:xs) = ((rev xs) ++ [x])
public class Algorithms {public static int reverseInt(int n) {int reversed = 0;while(n != 0){reversed = reversed * 10 + (n % 10);n /= 10;}return reversed;}}- module ReverseDigs where
- revDigs :: Integer -> Integer
- revDigs = read . rev . show
- where
- rev :: [Char] -> [Char]
- rev [] = []
- rev (x:xs) = ((rev xs) ++ [x])
module ReverseDigsSpec where import ReverseDigs import Test.Hspec import Test.QuickCheck palindrome :: Integer -> Integer palindrome x = read $ s ++ reverse s where s = show x -- TODO: Replace examples and use TDD development by writing your own tests spec :: Spec spec = do describe "Reverse ints" $ do it "Should reverse ints" $ do revDigs 54321 `shouldBe` (12345 :: Integer) it "Should leave palindromic numbers" $ property $ forAll (choose (1, 1000)) $ \int -> revDigs (palindrome int) `shouldBe` (palindrome int)
import org.junit.Test;import static org.junit.Assert.assertEquals;import org.junit.runners.JUnit4;- module ReverseDigsSpec where
- import ReverseDigs
- import Test.Hspec
- import Test.QuickCheck
// TODO: Replace examples and use TDD development by writing your own tests- palindrome :: Integer -> Integer
- palindrome x = read $ s ++ reverse s
- where s = show x
- -- TODO: Replace examples and use TDD development by writing your own tests
public class SolutionTest {@Testpublic void reverseIntTest() {assertEquals(54321, Algorithms.reverseInt(12345));}}- spec :: Spec
- spec = do
- describe "Reverse ints" $ do
- it "Should reverse ints" $ do
- revDigs 54321 `shouldBe` (12345 :: Integer)
- it "Should leave palindromic numbers" $ property $
- forAll (choose (1, 1000)) $ \int ->
- revDigs (palindrome int) `shouldBe` (palindrome int)
def prime_checker(n): if n in [2, 3, 5]: return True elif n % 2 == 0 or n % 3 == 0 or n % 5 == 0: return False a = int(n ** 0.5 / 30) b = [7, 11, 13, 17, 19, 23, 29, 31] for i in [30 * j for j in range(a + 1)]: if True in [n % (i + q) == 0 for q in b if i + q is not n]: return False return True
"""https://en.wikipedia.org/wiki/Primality_testThis one has lesser tests or usage of % operator.An alternative using primality mod 30 = 2 * 3 * 5 instead of 6 = 2 * 3"""- def prime_checker(n):
- if n in [2, 3, 5]:
- return True
- elif n % 2 == 0 or n % 3 == 0 or n % 5 == 0:
- return False
- a = int(n ** 0.5 / 30)
- b = [7, 11, 13, 17, 19, 23, 29, 31]
- for i in [30 * j for j in range(a + 1)]:
- if True in [n % (i + q) == 0 for q in b if i + q is not n]:
- return False
- return True
public static class Kata { public static bool IsOdd(int i) => (i & 1) == 1; }
- public static class Kata
- {
public static bool IsOdd(int input){return ((input % 10 == 1) || (input % 10 == 3) || (input % 10 == 5) || (input % 10 == 7) || (input % 10 == 9));}- public static bool IsOdd(int i) => (i & 1) == 1;
- }