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.
look ma, only one space!
~
a more maximalist version with type annotations like a java programmer who is learning python. But wait... a twist, mypy doesn't like this if you check the type annotations, a really good writeup of the issue can be found here: https://stackoverflow.com/questions/69334475/how-to-hint-at-number-types-i-e-subclasses-of-number-not-numbers-themselv/69383462#69383462. I hope I get to share this bit of serendipity with someone one day.
from numbers import Number def kube (l: Number, w: Number, h: Number) -> Number: if any(not isinstance(x, Number) for x in (l, w, h)): raise TypeError("sides must be numeric") if any(x < 0 for x in (l, w, h)): raise ValueError("Cube edges must have positive length") else: return l * w * h
kube = lambda l, w, h: "Invalid Cube" if any(x < 0 for x in (l, w, h)) else l * w * h- from numbers import Number
- def kube (l: Number, w: Number, h: Number) -> Number:
- if any(not isinstance(x, Number) for x in (l, w, h)):
- raise TypeError("sides must be numeric")
- if any(x < 0 for x in (l, w, h)):
- raise ValueError("Cube edges must have positive length")
- else:
- return l * w * h
import codewars_test as test # TODO Write tests from solution import kube # test.assert_equals(actual, expected, [optional] message) @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(kube(7, 9, 4), 252) test.assert_equals(kube(5, 12, 7), 420) test.assert_equals(kube(3, 7, 49), 1029) test.expect_error("shouldn't work with lists", lambda:kube([], 3, 99), exception=TypeError) test.expect_error("side lengths cant be negative", lambda:kube(-1,1,4), exception=ValueError)
- import codewars_test as test
- # TODO Write tests
- from solution import kube
- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
- test.assert_equals(kube(7, 9, 4), 252)
- test.assert_equals(kube(5, 12, 7), 420)
- test.assert_equals(kube(3, 7, 49), 1029)
test.assert_equals(kube(-1,1,4), "Invalid Cube")- test.expect_error("shouldn't work with lists", lambda:kube([], 3, 99), exception=TypeError)
- test.expect_error("side lengths cant be negative", lambda:kube(-1,1,4), exception=ValueError)
public class Kata { public static int SameCase(char a, char b) => (char.IsLower(a)&&char.IsLower(b)||char.IsUpper(a)&&char.IsUpper(b))? 1 : (char.IsLetter(a)&&char.IsLetter(b))? 0 : -1; }
- public class Kata {
public static int SameCase(char a, char b) {string letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";char tempA = a;char tempB = b;if((!letters.Contains(tempA = char.ToUpper(tempA)) && letters.Contains(tempB = char.ToUpper(tempB))) ||(!letters.Contains(tempB = char.ToUpper(tempB)) && letters.Contains(tempA = char.ToUpper(tempA))) ||(!letters.Contains(tempA = char.ToUpper(tempA)) && !letters.Contains(tempB = char.ToUpper(tempB)))) return -1;if(char.IsUpper(a) && char.IsUpper(b)){return 1;} else if (char.IsLower(a) && char.IsLower(b)){return 1;} else {return 0;}}- public static int SameCase(char a, char b) => (char.IsLower(a)&&char.IsLower(b)||char.IsUpper(a)&&char.IsUpper(b))? 1 : (char.IsLetter(a)&&char.IsLetter(b))? 0 : -1;
- }