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.
class StringReversal: """String reversal class.""" def __init__(self, param=None): """Initialize attributes.""" self.pram = param self.output = '' def reversal(self): """Reverses self.param, and returns the value""" for i in range(len(str(self.pram)) - 1, -1, -1): self.output += str(self.pram)[i] if isinstance(self.pram, (dict, list, set, tuple)): return f'{self.output[-1:]}{self.output[1:-1]}{self.output[:1]}' return self.output
//import java.util.Scanner;import java.lang.StringBuilder;- class StringReversal:
- """String reversal class."""
public class Practice01{public static String reverse(String input) {/*Scanner sc = new Scanner(System.in);System.out.println("Give the desired string to be reversed :");String e = sc.nextLine();*/return new StringBuilder(input).reverse().toString();}}- def __init__(self, param=None):
- """Initialize attributes."""
- self.pram = param
- self.output = ''
- def reversal(self):
- """Reverses self.param, and returns the value"""
- for i in range(len(str(self.pram)) - 1, -1, -1):
- self.output += str(self.pram)[i]
- if isinstance(self.pram, (dict, list, set, tuple)):
- return f'{self.output[-1:]}{self.output[1:-1]}{self.output[:1]}'
- return self.output
import unittest from solution import StringReversal class TestStringReversal(unittest.TestCase): def setUp(self) -> None: s = StringReversal() self.string_samples = ( (StringReversal('Hello World!').reversal(), '!dlroW olleH'), (StringReversal('codeWars').reversal(), 'sraWedoc'), (StringReversal('abc 123').reversal(), '321 cba'), (StringReversal('0123456789').reversal(), '9876543210'), (StringReversal('').reversal(), ''), (StringReversal('-1 - 2 - 3 - 4').reversal(), '4 - 3 - 2 - 1-')) self.number_samples = ( (StringReversal(123456789).reversal(), '987654321'), (StringReversal(123.987).reversal(), '789.321'), (StringReversal(-123456789).reversal(), '987654321-'), (StringReversal(1.0000000000000002).reversal(), '2000000000000000.1'), (StringReversal(100110101011001101111).reversal(), '111101100110101011001')) self.mix_datatypes = ( (StringReversal([1, 2, 3]).reversal(), '[3 ,2 ,1]'), (StringReversal((1, 2, 3)).reversal(), '(3 ,2 ,1)'), (StringReversal({1: 'a', 2: 'b', 3: 'c'}).reversal(), "{'c' :3 ,'b' :2 ,'a' :1}"),) def test_reverse_strings(self): """Tests reverse string function on strings.""" for sample, expected in self.string_samples: self.assertEqual(sample, expected) def test_reverse_numbers(self): """Tests reverse string function on numbers.""" for sample, expected in self.number_samples: self.assertEqual(sample, expected) def test_reverse_mixed_datatypes(self): """Tests reverse string function on mix data types.""" for sample, expected in self.mix_datatypes: self.assertEqual(sample, expected) if __name__ == '__main__': unittest.main()
import static org.junit.Assert.*;import org.junit.Test;- import unittest
- from solution import StringReversal
// TODO: Replace examples and use TDD by writing your own testspublic class Practice01Test {private static void testing(String actual, String expected) {assertEquals(expected, actual);}@Testpublic void test() {testing("!ereht olleH" , Practice01.reverse("Hello there!"));}}- class TestStringReversal(unittest.TestCase):
- def setUp(self) -> None:
- s = StringReversal()
- self.string_samples = (
- (StringReversal('Hello World!').reversal(), '!dlroW olleH'),
- (StringReversal('codeWars').reversal(), 'sraWedoc'),
- (StringReversal('abc 123').reversal(), '321 cba'),
- (StringReversal('0123456789').reversal(), '9876543210'),
- (StringReversal('').reversal(), ''),
- (StringReversal('-1 - 2 - 3 - 4').reversal(), '4 - 3 - 2 - 1-'))
- self.number_samples = (
- (StringReversal(123456789).reversal(), '987654321'),
- (StringReversal(123.987).reversal(), '789.321'),
- (StringReversal(-123456789).reversal(), '987654321-'),
- (StringReversal(1.0000000000000002).reversal(), '2000000000000000.1'),
- (StringReversal(100110101011001101111).reversal(), '111101100110101011001'))
- self.mix_datatypes = (
- (StringReversal([1, 2, 3]).reversal(), '[3 ,2 ,1]'),
- (StringReversal((1, 2, 3)).reversal(), '(3 ,2 ,1)'),
- (StringReversal({1: 'a', 2: 'b', 3: 'c'}).reversal(), "{'c' :3 ,'b' :2 ,'a' :1}"),)
- def test_reverse_strings(self):
- """Tests reverse string function on strings."""
- for sample, expected in self.string_samples:
- self.assertEqual(sample, expected)
- def test_reverse_numbers(self):
- """Tests reverse string function on numbers."""
- for sample, expected in self.number_samples:
- self.assertEqual(sample, expected)
- def test_reverse_mixed_datatypes(self):
- """Tests reverse string function on mix data types."""
- for sample, expected in self.mix_datatypes:
- self.assertEqual(sample, expected)
- if __name__ == '__main__':
- unittest.main()
fn solution(mut x: i32) -> bool { match x.to_string().chars().into_iter().position(|s| s == '3') { Some(_t) => true, _e => false, } }
- fn solution(mut x: i32) -> bool {
for d in x.to_string().chars() {if d == '3' {return true;}- match x.to_string().chars().into_iter().position(|s| s == '3') {
- Some(_t) => true,
- _e => false,
- }
false- }
increment_string = lambda s, i=lambda s: next((len(s)-e for e,x in enumerate(s[::-1]) if not x.isdigit()), 0): s[:i(s)] + f'{int(s[i(s):] or 0) + 1}'.rjust(len(s[i(s):]), "0")
import redef increment_string(s):end_nums = re.match(".+?(\d+)$", s)if end_nums:padded_number = '{:0>{}}'.format(int(end_nums[1])+1, len(end_nums[1]))return s[:end_nums.span(1)[0]] + padded_numberreturn s + '1'- increment_string = lambda s, i=lambda s: next((len(s)-e for e,x in enumerate(s[::-1]) if not x.isdigit()), 0): s[:i(s)] + f'{int(s[i(s):] or 0) + 1}'.rjust(len(s[i(s):]), "0")
Going for style points