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.
def est_height(gender, dad_height, mom_height): return (dad_height+mom_height+1)/2 if gender == "boy" else (dad_height+mom_height-1)/2
import statistics- def est_height(gender, dad_height, mom_height):
avg = statistics.mean([dad_height, mom_height])return avg + 0.5 if gender is "boy" else avg - 0.5- return (dad_height+mom_height+1)/2 if gender == "boy" else (dad_height+mom_height-1)/2
reverse_string = lambda n:n[::-1]
reverse_string = lambda n: n[::-1]- reverse_string = lambda n:n[::-1]
import codewars_test as test from solution import reverse_string @test.describe("Solution") def a(): @test.it("should test for something") def a(): test.assert_equals(reverse_string('abc'), 'cba') test.assert_equals(reverse_string('123'), '321') test.assert_equals(reverse_string('a1b2c3'), '3c2b1a') test.assert_equals(reverse_string('Hello World!'), '!dlroW olleH') test.assert_equals(reverse_string('Capre diem'), 'meid erpaC') test.assert_equals(reverse_string('Lorem ipsum dolor sit amet!'), '!tema tis rolod muspi meroL')
- import codewars_test as test
- from solution import reverse_string
- @test.describe("Solution")
- def a():
- @test.it("should test for something")
- def a():
- test.assert_equals(reverse_string('abc'), 'cba')
- test.assert_equals(reverse_string('123'), '321')
- test.assert_equals(reverse_string('a1b2c3'), '3c2b1a')
- test.assert_equals(reverse_string('Hello World!'), '!dlroW olleH')
- test.assert_equals(reverse_string('Capre diem'), 'meid erpaC')
- test.assert_equals(reverse_string('Lorem ipsum dolor sit amet!'), '!tema tis rolod muspi meroL')
Prime Optimization
import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.Arrays; public class PasswordValidation { private static final String TODAY_DATE = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); private static final String[] VALID_MONTHS = { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" }; private static final int[] PRIME = {23,29,31,37,41,43,47}; public static boolean validatePassword(String password) { if (password.length() < 20 || password.length() > 50 || Arrays.binarySearch(PRIME, password.length()) < 0 || !password.contains(String.valueOf(password.length())) || !password.contains(TODAY_DATE) || !Arrays.stream(VALID_MONTHS).anyMatch(s -> password.toLowerCase().contains(s))) return false; else if (!password.matches(("(.*[A-Z].*){3,}")) || !password.matches("(.*[a-z].*){1,}") || !password.matches("(.*[-._@#$&].*){1,}") || password.matches(".*[-._@#$&][-._@#$&].*")) return false; else if (Arrays.stream(password.split("")).filter(s -> s.matches("[0-9]")).mapToInt(s -> Integer.valueOf(s)).sum() < 25) return false; else return true; } }
- import java.time.LocalDate;
- import java.time.format.DateTimeFormatter;
- import java.util.Arrays;
- public class PasswordValidation {
- private static final String TODAY_DATE = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
private static final String[] VALID_MONTHS = { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct","nov", "dec" };- private static final String[] VALID_MONTHS = { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" };
- private static final int[] PRIME = {23,29,31,37,41,43,47};
- public static boolean validatePassword(String password) {
if (password.length() < 20 || password.length() > 50 || !isPrime(password.length())- if (password.length() < 20 || password.length() > 50 || Arrays.binarySearch(PRIME, password.length()) < 0
- || !password.contains(String.valueOf(password.length())) || !password.contains(TODAY_DATE)
- || !Arrays.stream(VALID_MONTHS).anyMatch(s -> password.toLowerCase().contains(s)))
- return false;
- else if (!password.matches(("(.*[A-Z].*){3,}"))
- || !password.matches("(.*[a-z].*){1,}")
- || !password.matches("(.*[-._@#$&].*){1,}")
- || password.matches(".*[-._@#$&][-._@#$&].*"))
- return false;
- else if (Arrays.stream(password.split("")).filter(s -> s.matches("[0-9]")).mapToInt(s -> Integer.valueOf(s)).sum() < 25)
- return false;
- else return true;
- }
public static boolean isPrime(int n) {for (int i = 2; i <= Math.sqrt(n); i++) {if (n % i == 0)return false;}return true;}- }