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.
import java.util.*; /** an object of class blah author date */ class Vehicle { /**I make up the class invariant, I describe speed limit*/ final int SPEED_LIMIT = 60; /**I make up the class invariant, i describe current speed*/ int currentSpeed; public void setCurrentSpeed(int[] accelerations) { currentSpeed = Arrays.stream(accelerations).sum(); } /**i describe current speed*/ public int getCurrentSpeed() { return currentSpeed; } /**i describe within speed limit*/ public boolean isWithinSpeedLimit() { return getCurrentSpeed() <= SPEED_LIMIT; } }
- import java.util.*;
- /**
- an object of class blah
- author
- date
- */
- class Vehicle {
- /**I make up the class invariant, I describe speed limit*/
- final int SPEED_LIMIT = 60;
- /**I make up the class invariant, i describe current speed*/
- int currentSpeed;
/** */- public void setCurrentSpeed(int[] accelerations) {
- currentSpeed = Arrays.stream(accelerations).sum();
- }
- /**i describe current speed*/
- public int getCurrentSpeed() {
- return currentSpeed;
- }
- /**i describe within speed limit*/
- public boolean isWithinSpeedLimit() {
- return getCurrentSpeed() <= SPEED_LIMIT;
- }
- }
aaaaaaaaaaaaaaaaaaaaaaaaa
I don't think mine is correct since the "golfed" part was the return type.
Readable
public static class Kata { public static int SameCase(char a, char b) { if (!char.IsLetter(a) || !char.IsLetter(b)) return -1; return char.IsUpper(a) == char.IsUpper(b) ? 1 : 0; } }
- public static class Kata
- {
public static int SameCase(char a, char b) =>(!char.IsLetter(a) || !char.IsLetter(b)) ? -1 :(char.IsLower(a) == char.IsLower(b)) ? 1 : 0;- public static int SameCase(char a, char b)
- {
- if (!char.IsLetter(a) || !char.IsLetter(b))
- return -1;
- return char.IsUpper(a) == char.IsUpper(b) ? 1 : 0;
- }
- }
import kotlin.test.Test import kotlin.test.assertEquals class ReturnIntTest { @Test fun return_int_test() { assertEquals(return_int(10), 10); } }
#[test]fn return_int_test() {assert_eq!(return_int(10), 10);- import kotlin.test.Test
- import kotlin.test.assertEquals
- class ReturnIntTest {
- @Test
- fun return_int_test() {
- assertEquals(return_int(10), 10);
- }
- }
???
Greet=lambda : "".join(map(chr,[x for x in (72,101,108,108,111,32,87,111,114,108,100) if isinstance(x,int)]))
function Greet(){return "Hello World!"}- Greet=lambda : "".join(map(chr,[x for x in (72,101,108,108,111,32,87,111,114,108,100) if isinstance(x,int)]))
import codewars_test as test # TODO Write tests import solution # or from solution import example # 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(solution.Greet(),"Hello World")
// 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");- import codewars_test as test
- # TODO Write tests
- import solution # or from solution import example
describe("Solution", function() {it("should test for something", function() {// Test.assertEquals(1 + 1, 2);// assert.strictEqual(1 + 1, 2);});});- # 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(solution.Greet(),"Hello World")
class Human: def __init__(self, mouth=None): self.mouth = mouth self.anus = None def __str__(self): return self.mouth class CentipedeLinkedList: def __init__(self): self.head = None def __str__(self): return self.head def display_segments(self): body = self.head while body is not None: print(f'😮️-{body.mouth}💩', end='') body = body.anus def insert_new_head(self, new_body): NewBody = Human(new_body) NewBody.anus = self.head self.head = NewBody def insert_tail(self, new_body): NewBody = Human(new_body) if self.head is None: self.head = NewBody return None lips = self.head while lips.anus: lips = lips.anus lips.anus = NewBody def get_count(self): temp = self.head count = 0 while temp: count += 1 temp = temp.anus return count def search(self, segment): temp = self.head while temp is not None: if segment == temp.mouth: return True else: temp = temp.anus return False
- class Human:
- def __init__(self, mouth=None):
- self.mouth = mouth
- self.anus = None
- def __str__(self):
- return self.mouth
- class CentipedeLinkedList:
- def __init__(self):
- self.head = None
- def __str__(self):
- return self.head
- def display_segments(self):
- body = self.head
- while body is not None:
- print(f'😮️-{body.mouth}💩', end='')
- body = body.anus
- def insert_new_head(self, new_body):
- NewBody = Human(new_body)
- NewBody.anus = self.head
- self.head = NewBody
- def insert_tail(self, new_body):
- NewBody = Human(new_body)
- if self.head is None:
- self.head = NewBody
- return None
- lips = self.head
- while lips.anus:
- lips = lips.anus
- lips.anus = NewBody
def main():# Create Human Centipede List:human_centipede = CentipedeLinkedList()# Create centipede body part # 1human_centipede.head = Human('Katsuro')# Create centipede body part # 2jenny = Human('Jenny')# Create centipede body part # 3lindsay = Human('Lindsay')# Linking A to Bhuman_centipede.head.anus = jenny# Linking B to Cjenny.anus = lindsay# Display the beautiful three-Node construction!!human_centipede.display_segments()# Add a new head to the Centipedehuman_centipede.insert_new_head('martin')# Add a new tail to the centipedehuman_centipede.insert_tail('Karrie')- def get_count(self):
- temp = self.head
- count = 0
- while temp:
- count += 1
- temp = temp.anus
- return count
- def search(self, segment):
- temp = self.head
- while temp is not None:
- if segment == temp.mouth:
- return True
- else:
- temp = temp.anus
- return False
if __name__ == '__main__':main()
import unittest from solution import Human, CentipedeLinkedList class TestHumanCentipedeLinkedList(unittest.TestCase): def setUp(self) -> None: # Create Human Centipede List: self.human_centipede = CentipedeLinkedList() # Create centipede body part # 1 self.human_centipede.head = Human('Katsuro') # Create centipede body part # 2 jenny = Human('Jenny') # Create centipede body part # 3 lindsay = Human('Lindsay') # Linking A to B self.human_centipede.head.anus = jenny # Linking B to C jenny.anus = lindsay def test_length_count(self): """Test count function""" self.assertEqual(self.human_centipede.get_count(), 3) def test_search_segment_True(self): """Test search function for True""" segments = ['Katsuro', 'Jenny','Lindsay'] for seg in segments: self.assertEqual(self.human_centipede.search(seg), True) def test_search_segment_False(self): """Test search function for False""" segments = ['Jon', 'Amy','Brian'] for seg in segments: self.assertEqual(self.human_centipede.search(seg), False) def test_new_head_segment(self): """Test Ad new segment function""" self.human_centipede.insert_new_head('Martin') self.assertEqual(self.human_centipede.search('Martin'), True) if __name__ == '__main__': unittest.main()
import codewars_test as test# TODO Write testsimport solution # or from solution import example# 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)- import unittest
- from solution import Human, CentipedeLinkedList
- class TestHumanCentipedeLinkedList(unittest.TestCase):
- def setUp(self) -> None:
- # Create Human Centipede List:
- self.human_centipede = CentipedeLinkedList()
- # Create centipede body part # 1
- self.human_centipede.head = Human('Katsuro')
- # Create centipede body part # 2
- jenny = Human('Jenny')
- # Create centipede body part # 3
- lindsay = Human('Lindsay')
- # Linking A to B
- self.human_centipede.head.anus = jenny
- # Linking B to C
- jenny.anus = lindsay
- def test_length_count(self):
- """Test count function"""
- self.assertEqual(self.human_centipede.get_count(), 3)
- def test_search_segment_True(self):
- """Test search function for True"""
- segments = ['Katsuro', 'Jenny','Lindsay']
- for seg in segments:
- self.assertEqual(self.human_centipede.search(seg), True)
- def test_search_segment_False(self):
- """Test search function for False"""
- segments = ['Jon', 'Amy','Brian']
- for seg in segments:
- self.assertEqual(self.human_centipede.search(seg), False)
- def test_new_head_segment(self):
- """Test Ad new segment function"""
- self.human_centipede.insert_new_head('Martin')
- self.assertEqual(self.human_centipede.search('Martin'), True)
- if __name__ == '__main__':
- unittest.main()