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 returnInputNumber(n: int): return len(str('meow ' * n).split(' ')) - 1 if n > 0 else n
- def returnInputNumber(n: int):
s = []for i in range (abs(n),2*abs(n)):s.append("meow")return len(s) if n>0 else -len(s)- return len(str('meow ' * n).split(' ')) - 1 if n > 0 else n
import codewars_test as test from solution import returnInputNumber @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(returnInputNumber(0), 0) test.assert_equals(returnInputNumber(-10), -10) test.assert_equals(returnInputNumber(3), 3)
- import codewars_test as test
- from solution import returnInputNumber
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
- test.assert_equals(returnInputNumber(0), 0)
- test.assert_equals(returnInputNumber(-10), -10)
- test.assert_equals(returnInputNumber(3), 3)
did it with a dictionary treating a dictionary like a hashmap, it should* run in O(n+m) time with O(n+m) space, where n is the length of s1 and m is the length of s2. Though...it could also take up double** the space required as compared to the sorting method. lol
*Dropping the constants **When including dropped constants
def anagrams(s1,s2): if s1 and s2: d={} for c in s1: if c in d: d[c]+=1 else: d[c]=1 dd={} for c in s2: if c in dd: dd[c]+=1 else: dd[c]=1 for k in d: if k not in dd or dd[k]!=d[k]: return False for k in dd: if k not in d or d[k]!=dd[k]: return False return True return s1==None and s2==None
anagrams=lambda a,b:sorted(a)==sorted(b)- def anagrams(s1,s2):
- if s1 and s2:
- d={}
- for c in s1:
- if c in d:
- d[c]+=1
- else:
- d[c]=1
- dd={}
- for c in s2:
- if c in dd:
- dd[c]+=1
- else:
- dd[c]=1
- for k in d:
- if k not in dd or dd[k]!=d[k]:
- return False
- for k in dd:
- if k not in d or d[k]!=dd[k]:
- return False
- return True
- return s1==None and s2==None