Start a new Kumite
AllAgda (Beta)BF (Beta)CCFML (Beta)ClojureCOBOL (Beta)CoffeeScriptCommonLisp (Beta)CoqC++CrystalC#D (Beta)DartElixirElm (Beta)Erlang (Beta)Factor (Beta)Forth (Beta)Fortran (Beta)F#GoGroovyHaskellHaxe (Beta)Idris (Beta)JavaJavaScriptJulia (Beta)Kotlinλ Calculus (Beta)LeanLuaNASMNim (Beta)Objective-C (Beta)OCaml (Beta)Pascal (Beta)Perl (Beta)PHPPowerShell (Beta)Prolog (Beta)PureScript (Beta)PythonR (Beta)RacketRaku (Beta)Reason (Beta)RISC-V (Beta)RubyRustScalaShellSolidity (Beta)SQLSwiftTypeScriptVB (Beta)
Show only mine

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.

Ad
Ad
Code
Diff
  • def even_or_odd(number):
        return 'Even' if number % 2 == 0 else 'Odd'
    • def even_or_odd(number):
    • while True:
    • if number % 2 == 0:
    • return 'Even'
    • else:
    • return 'Odd'
    • return 'Even' if number % 2 == 0 else 'Odd'
Code
Diff
  • 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

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

Code
Diff
  • 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
Code
Diff
  • print([i for i in range(0, 51, 2) if i % 3 != 0])                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ("hello")
    • print ("hello")
    • print([i for i in range(0, 51, 2) if i % 3 != 0]) ("hello")