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
  • fizz_buzz = lambda m: ['Fizz'*(not n%3)+'Buzz'*(not n%5) or n for n in range(1,m)]
    • def fizz_buzz(m):
    • return ["Fizz"*(n%3==0)+"Buzz"*(n%5==0) if (n%3==0 or n%5==0) else n for n in range(1,m)]
    • fizz_buzz = lambda m: ['Fizz'*(not n%3)+'Buzz'*(not n%5) or n for n in range(1,m)]
Code
Diff
  • from functools import reduce
    prod =lambda n:reduce(lambda x,y:x*y,n if n else[0])
    • from itertools import product
    • def prod(n):
    • if not n:return 0
    • n = n[-1]
    • fact = lambda x: x if x <= 2 else x*fact(x-1)
    • return fact(n)
    • from functools import reduce
    • prod =lambda n:reduce(lambda x,y:x*y,n if n else[0])
Algorithms
Logic
Code
Diff
  • def get_nth_words(text, n):
        return '' if n <= 0 else ' '.join([word for word in text.split()][n - 1::n])
    • def get_nth_words(text, n):
    • if n <= 0:
    • return ""
    • words = text.split()
    • nth_words = [word for word in words[n-1 : : n]]
    • return " ".join(nth_words)
    • return '' if n <= 0 else ' '.join([word for word in text.split()][n - 1::n])
Code
Diff
  • def verify_sum(a,b)
      return false if a.nil? || b.nil?
    
      a.sum == b.sum
    end
    • def verify_sum(a,b)a.sum==b.sum rescue !1end
    • def verify_sum(a,b)a&&b&&a.sum==b.sum||!1end
    • def verify_sum(a,b)
    • return false if a.nil? || b.nil?
    • a.sum == b.sum
    • end
Code
Diff
  • int reverse_int_recc(int num, int rev) {
        return (num == 0) ? rev : reverse_int_recc(num / 10, rev * 10 + (num % 10));
    }
    
    int reverse_int(int num) {
        return reverse_int_recc(num, 0);
    }
    
    • int reverse_int(int num)
    • {
    • int rev = 0;
    • num *= 10;
    • while(num /= 10)
    • rev = rev * 10 + num % 10;
    • return rev;
    • }
    • int reverse_int_recc(int num, int rev) {
    • return (num == 0) ? rev : reverse_int_recc(num / 10, rev * 10 + (num % 10));
    • }
    • int reverse_int(int num) {
    • return reverse_int_recc(num, 0);
    • }
Code
Diff
  • converter = lambda n: ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"][n] if n < 10 else None
    • def converter(number):
    • try:
    • return ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"][number]
    • except IndexError:
    • return None
    • converter = lambda n: ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"][n] if n < 10 else None
Games
Arrays
Data Types
Algorithms
Logic

Very readable solution (though not tail-recursive).
Could be used as spec for quick check based tests in case a more performant solution is required.

Code
Diff
  • module Platforms where
    
    platforms :: [Integer] -> Integer
    platforms (x:y:xs) = abs (x - y) + platforms (y:xs)
    platforms _        = 0
    • module Platforms where
    • platforms :: [Integer] -> Integer
    • platforms xs = sum $ zipWith energy xs (tail xs)
    • where
    • energy x y = abs (x - y)
    • platforms (x:y:xs) = abs (x - y) + platforms (y:xs)
    • platforms _ = 0