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 replicate(times, num): if times<=0: return [] else: return [num]+replicate(times-1,num) print(replicate(8,5))
- def replicate(times, num):
return [] if times <= 0 else [num] + replicate(times-1, num)replicate(8,5)- if times<=0:
- return []
- else:
- return [num]+replicate(times-1,num)
- print(replicate(8,5))
extension String { func insert(_ value: String, n: Int) -> String { guard n > 0 else { return self } var result: String = "" stride(from: 0, to: self.count, by: n).forEach { i in let startIndex = self.index(self.startIndex, offsetBy: i) let endIndex = self.index(startIndex, offsetBy: n, limitedBy: self.endIndex) ?? self.endIndex result += (result.isEmpty ? "" : value) + self[startIndex..<endIndex] } return result } }
- extension String {
- func insert(_ value: String, n: Int) -> String {
guard n > 0 else {return self}var ndx = 0return self.reduce("") { (string, c) inguard ndx < n else {ndx = 1return "\(string)\(value)\(c)"}ndx += 1return "\(string)\(c)"- guard n > 0 else { return self }
- var result: String = ""
- stride(from: 0, to: self.count, by: n).forEach { i in
- let startIndex = self.index(self.startIndex, offsetBy: i)
- let endIndex = self.index(startIndex, offsetBy: n, limitedBy: self.endIndex) ?? self.endIndex
- result += (result.isEmpty ? "" : value) + self[startIndex..<endIndex]
- }
- return result
- }
- }
import codewars_test as test # TODO Write tests import solution # or from solution import example # test.assert_equals(actual, expected, [optional] message) @test.describe("Check:") def test_group(): @test.it("Some simple cases") def test_case(): test.assert_equals(power(2,5), 2**5) test.assert_equals(power(3,50), 3**50) test.assert_equals(power(2,200), 2**200) test.assert_equals(power(200,0), 1)
- import codewars_test as test
- # TODO Write tests
- import solution # or from solution import example
- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Check:")
- def test_group():
- @test.it("Some simple cases")
- def test_case():
- test.assert_equals(power(2,5), 2**5)
- test.assert_equals(power(3,50), 3**50)
- test.assert_equals(power(2,200), 2**200)
- test.assert_equals(power(200,0), 1)