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.
We want to know wether there are more words which have a greater alphabetic value than numeric value, to do this we will sum the values of the letters and we will have to compare them with the result of the multiplication of the numbers.
If there are more words that have a greater alphabetic value we will return -1, if it's all the way around and there are more words which multiplication of their numbers is greater we will return 1 and if there are the same amount of words on both ends we will return 0.
To make this clear here are some examples:
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 hiddenTest() { assertEquals(0,""); assertEquals(0,"a1"); assertEquals(1,"a1b2c3 d4e5f6"); } @Test void randomTests() { String allChars = "abcdefghijklmnopqrstuvwxyz1234567890"; StringBuilder randomString = new StringBuilder(); for(int repetitions=0;repetitions<100;repetitions++) { randomString.setLength(0); int finalStringLength =(int) (Math.random() * 100); for(int i=0;i<finalStringLength;i++) { int currentWordLength = (int) (Math.random() * 20); for(int j=0;j<currentWordLength;j++) { randomString.append(allChars.charAt((int)(Math.random() * 35))).append(" "); } randomString.deleteCharAt(randomString.length()-1); } assertEquals("nuestroCodigo","codigoUsuario(randomString.toString())"); } } }
- 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 {
@Testvoid testSomething() {// assertEquals("expected", "actual");}- @Test
- void hiddenTest() {
- assertEquals(0,"");
- assertEquals(0,"a1");
- assertEquals(1,"a1b2c3 d4e5f6");
- }
- @Test
- void randomTests() {
- String allChars = "abcdefghijklmnopqrstuvwxyz1234567890";
- StringBuilder randomString = new StringBuilder();
- for(int repetitions=0;repetitions<100;repetitions++) {
- randomString.setLength(0);
- int finalStringLength =(int) (Math.random() * 100);
- for(int i=0;i<finalStringLength;i++) {
- int currentWordLength = (int) (Math.random() * 20);
- for(int j=0;j<currentWordLength;j++) {
- randomString.append(allChars.charAt((int)(Math.random() * 35))).append(" ");
- }
- randomString.deleteCharAt(randomString.length()-1);
- }
- assertEquals("nuestroCodigo","codigoUsuario(randomString.toString())");
- }
- }
- }
class UserInfo: def __init__(self, *args): self.first_name, self.last_name, self.age, self.job, self.hobbies = args def __getattr__(self, name): match name: case "full_name": return f'{self.first_name} {self.last_name}' case "email": return f'{self.first_name[0]}{self.last_name}@matrix.com'
from dataclasses import dataclass, field@dataclass- class UserInfo:
first_name: strlast_name: strage: intjob: strhobbies: list@propertydef full_name(self):return f'{self.first_name} {self.last_name}'@propertydef email(self):return f'{self.first_name[0]}{self.last_name}@matrix.com'- def __init__(self, *args):
- self.first_name, self.last_name, self.age, self.job, self.hobbies = args
- def __getattr__(self, name):
- match name:
- case "full_name":
- return f'{self.first_name} {self.last_name}'
- case "email":
- return f'{self.first_name[0]}{self.last_name}@matrix.com'
One new test.
import codewars_test as test from solution import simon_says @test.describe("Example") def test_group(): @test.it("test case 1: Simon says") def test_case(): test.assert_equals(simon_says('simon says, "The first rule of Fight Club is you do not talk about Fight Club."'), "The first rule of Fight Club is you do not talk about Fight Club.") test.assert_equals(simon_says('Simon Says, "eat, sleep, code, repeat"'), "eat, sleep, code, repeat") test.assert_equals(simon_says('SImoN SAYS, "practice python"'), "practice python") test.assert_equals(simon_says('sIMON says "type faster"'), "type faster") test.assert_equals(simon_says('Simon Says, ""'), "") test.assert_equals(simon_says('SImOn sAys, do your homework.'), "do your homework.") test.assert_equals(simon_says('SIMON SAYS obey the Zen of Python!'), "obey the Zen of Python!") test.assert_equals(simon_says('SIMON SAYS obey the Zen of Python!'), "obey the Zen of Python!") test.assert_equals(simon_says('SIMON SAYS,that python is slow'), "that python is slow") @test.it("test case 2: Simon didn't say") def test_case(): test.assert_equals(simon_says('seraph said, "The second rule of Fight Club is you do not talk about Fight Club." "'), 'You didn\'t say, "Simon says"!') test.assert_equals(simon_says('I said, "coffee makes code"'), 'You didn\'t say, "Simon says"!') test.assert_equals(simon_says('Simon say, "practice makes perfect"'), 'You didn\'t say, "Simon says"!') test.assert_equals(simon_says('Simon sayss, "gotcha!!"'), 'You didn\'t say, "Simon says"!') test.assert_equals(simon_says('Simon s ay, "jump high!"'), 'You didn\'t say, "Simon says"!') test.assert_equals(simon_says('.simon says, "take a break"'), 'You didn\'t say, "Simon says"!')
- import codewars_test as test
- from solution import simon_says
- @test.describe("Example")
- def test_group():
- @test.it("test case 1: Simon says")
- def test_case():
- test.assert_equals(simon_says('simon says, "The first rule of Fight Club is you do not talk about Fight Club."'), "The first rule of Fight Club is you do not talk about Fight Club.")
- test.assert_equals(simon_says('Simon Says, "eat, sleep, code, repeat"'), "eat, sleep, code, repeat")
- test.assert_equals(simon_says('SImoN SAYS, "practice python"'), "practice python")
- test.assert_equals(simon_says('sIMON says "type faster"'), "type faster")
- test.assert_equals(simon_says('Simon Says, ""'), "")
- test.assert_equals(simon_says('SImOn sAys, do your homework.'), "do your homework.")
- test.assert_equals(simon_says('SIMON SAYS obey the Zen of Python!'), "obey the Zen of Python!")
- test.assert_equals(simon_says('SIMON SAYS obey the Zen of Python!'), "obey the Zen of Python!")
- test.assert_equals(simon_says('SIMON SAYS,that python is slow'), "that python is slow")
- @test.it("test case 2: Simon didn't say")
- def test_case():
- test.assert_equals(simon_says('seraph said, "The second rule of Fight Club is you do not talk about Fight Club." "'), 'You didn\'t say, "Simon says"!')
- test.assert_equals(simon_says('I said, "coffee makes code"'), 'You didn\'t say, "Simon says"!')
- test.assert_equals(simon_says('Simon say, "practice makes perfect"'), 'You didn\'t say, "Simon says"!')
- test.assert_equals(simon_says('Simon sayss, "gotcha!!"'), 'You didn\'t say, "Simon says"!')
- test.assert_equals(simon_says('Simon s ay, "jump high!"'), 'You didn\'t say, "Simon says"!')
test.assert_equals(simon_says('.simon says, "take a break"'), 'You didn\'t say, "Simon says"!')- test.assert_equals(simon_says('.simon says, "take a break"'), 'You didn\'t say, "Simon says"!')
class TemperatureConverter: def __init__(self, temp): self.temp = temp def fahrenheit_to_celsius(self): return round((self.temp - 32) * 5 / 9, 2) def celsius_to_fahrenheit(self): return round((self.temp * 9 / 5) + 32, 2)
- class TemperatureConverter:
- def __init__(self, temp):
- self.temp = temp
- def fahrenheit_to_celsius(self):
pass- return round((self.temp - 32) * 5 / 9, 2)
- def celsius_to_fahrenheit(self):
pass- return round((self.temp * 9 / 5) + 32, 2)
class KumiteFoo: def __init__(self, p): self.p = p self.condition = 'Yes' if len(self.p) and not sum(map(ord, self.p.lower())) % 324 else 'No' def solution(self): return self.condition
- class KumiteFoo:
- def __init__(self, p):
- self.p = p
- self.condition = 'Yes' if len(self.p) and not sum(map(ord, self.p.lower())) % 324 else 'No'
- def solution(self):
return 'Yes' if len(self.p) and not sum(map(ord, self.p.lower()))%324 else 'No'- return self.condition
import os, shutil class MoveFiles: def __init__(self): self.images = [img for img in os.listdir('folderA') if img.endswith(('.png', '.jpg', '.jpeg'))] def move_image_files(self): for img in self.images: shutil.move(os.path.join('folderA', img), os.path.join('folderB', img))
import shutilimport os- import os, shutil
- class MoveFiles:
- def __init__(self):
- self.images = [img for img in os.listdir('folderA') if img.endswith(('.png', '.jpg', '.jpeg'))]
- def move_image_files(self):
- for img in self.images:
new_path = os.path.join('folderB', img)shutil.move(os.path.join('folderA', img), new_path)- shutil.move(os.path.join('folderA', img), os.path.join('folderB', img))