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.

Algorithms
Logic
Fundamentals

A similar solution in Python.

Sorry about changing the format of the test cases, I copied the format from another Kumite because I don't know how to do it otherwise.

Code
Diff
  • def validateKey(key):
      segments = key.split('-')
      
      illegalSites = ["333", "444", "555", "666", "777", "888", "999"]
      illegalEnds = ["0", "8", "9"]
      
      return len(segments) == 2 and len(segments[0]) == 3 and len(segments[1]) == 7 and not segments[0] in illegalSites and not segments[1][-1:] in illegalEnds
    
    • function validateKey(key) {
    • var segments = key.split('-');
    • def validateKey(key):
    • segments = key.split('-')
    • var illegalSites = [333, 444, 555, 666, 777, 888, 999];
    • var illegalEnds = [0, 8, 9];
    • illegalSites = ["333", "444", "555", "666", "777", "888", "999"]
    • illegalEnds = ["0", "8", "9"]
    • if (segments.length != 2
    • || illegalSites.includes(+(segments[0])) || +(segments[0]) > 999 || +(segments[0]) < 0 || segments[0].length != 3
    • || +(segments[1]) % 7 == true || illegalEnds.includes(+(segments[1].slice(-1))) || segments[1].length != 7) {return false}
    • return true;
    • }
    • return len(segments) == 2 and len(segments[0]) == 3 and len(segments[1]) == 7 and not segments[0] in illegalSites and not segments[1][-1:] in illegalEnds

Recursion makes everything more elegant, right?

...right?

Code
Diff
  • import numpy
    
    def add(x, y):
        if x == 0 and y == 0:
            return 0
        elif y == 0:
            return add(x - numpy.sign(x), 0) + numpy.sign(x)
        else:
            return add(x, y - numpy.sign(y)) + numpy.sign(y)
    • from math import ceil, log10, sqrt
    • import numpy
    • def add(x, y):
    • return ceil(10 ** log10(ceil(sqrt(x**2 + 2*x*y + y**2))))
    • if x == 0 and y == 0:
    • return 0
    • elif y == 0:
    • return add(x - numpy.sign(x), 0) + numpy.sign(x)
    • else:
    • return add(x, y - numpy.sign(y)) + numpy.sign(y)
Logic
Mathematics
Algorithms
Numbers
Code
Diff
  • powerdistance(x)=2x-1
    • power_distance=lambda x:2*x-1
    • powerdistance(x)=2x-1
Code
Diff
  • find_max = max
    • def find_max(arr):
    • arr.sort()
    • return arr[-1]
    • find_max = max