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
Code
Diff
  • is_zero(N) :- N =:= 1.
    %
    • is_zero(N) :- N =:= 1.
    • is_zero(N) :- N =:= 1.
    • %
Code
Diff
  • from math import sqrt
    
    #Same but with some memoization, better if you need to check some numbers more than once
    def prime(x, cache={}): 
        if x not in cache:
            if x <= 1:
                cache[x]= False
                return False
            for i in range(2,int(sqrt(x))+1):
                if x % i is 0:
                    cache[x] = False
                    return False
            cache[x] = True        
        return cache[x]
    • from math import sqrt
    • #Same but with some memoization, better if you need to check some numbers more than once
    • def prime(x, cache={}):
    • if x not in cache:
    • if x <= 1:
    • cache[x]= False
    • return False
    • for i in range(2,int(sqrt(x))):
    • for i in range(2,int(sqrt(x))+1):
    • if x % i is 0:
    • cache[x] = False
    • return False
    • cache[x] = True
    • return cache[x]
Code
Diff
  • extension Int {
      var toBinary: Int {
        return (self < 0 ? -1 : 1) * (Int(String(abs(self), radix: 2)) ?? 0)
      }
    }
    • func binaryConverter(_ input: Int) -> Int {
    • //Your Code Here
    • return input
    • extension Int {
    • var toBinary: Int {
    • return (self < 0 ? -1 : 1) * (Int(String(abs(self), radix: 2)) ?? 0)
    • }
    • }
Tips & Tricks
Code
Diff
  • func printRandomNumber(in range: ClosedRange<Int>) {
      print(Int.random(in: range))
    }
    • import Glibc
    • for count in 1...20 {
    • print(random() % 100)
    • func printRandomNumber(in range: ClosedRange<Int>) {
    • print(Int.random(in: range))
    • }
Fundamentals
  • Write a function that takes an unsorted list of unique numbers ranging from 0 to 11.
  • Return a list that reverses the numeric differences step-by-step without changing the first number.
  • Numbers outside of the given range should be adjusted by modulus to stay within that range.

For example:

[7, 6, 4, 3, 1, 11, 10, 0, 9, 8, 2, 5]
should return 
[7, 8, 10, 11, 1, 3, 4, 2, 5, 6, 0, 9]
Code
Diff
  • def invert(tone_row):
        inversion = [tone_row[0]]
        for i in range(0, 11):
            inversion.append((inversion[i] + tone_row[i] - tone_row[i + 1]) % 12)
        return inversion
    • def invert(testset):
    • base12 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
    • invset = [(testset[0])]
    • for s in range(len(testset)-1):
    • interval = testset[s] - testset[s+1]
    • if s == 0:
    • inv_val = testset[s] + interval
    • if inv_val > 11:
    • inv_val = inv_val - 12
    • else:
    • inv_val += interval
    • if inv_val > 11:
    • inv_val = inv_val - 12
    • if inv_val < 0:
    • inv_abs = base12[inv_val]
    • else:
    • inv_abs = inv_val
    • invset.append(inv_abs)
    • return(invset)
    • def invert(tone_row):
    • inversion = [tone_row[0]]
    • for i in range(0, 11):
    • inversion.append((inversion[i] + tone_row[i] - tone_row[i + 1]) % 12)
    • return inversion
Code
Diff
  • def larger_than_5(a):
        return a>5 if True else False
    • def larger_than_5(a):
    • return True if a > 5 else False
    • return a>5 if True else False
Code
Diff
  • #include <stdlib.h>
    #include <string.h>
    
    char *my_strdup_1(const char *str) {
      const size_t len = strlen(str) + 1;
      char * const res = malloc(len);
      if (!res)
        return (NULL);
      memcpy(res, str, len);
      return res;
    }
    
    char *my_strdup_2(const char *str) {
      const size_t len = strlen(str) + 1;
      char * const res = malloc(len);
      if (!res)
        return (NULL);
      memcpy(res, str, len);
      return res;
    }
    
    • #include <stdlib.h>
    • #include <string.h>
    • char *my_strdup_1(const char *str) {
    • const size_t len = strlen(str);
    • char *const res = malloc(len); // <- BUG
    • const size_t len = strlen(str) + 1;
    • char * const res = malloc(len);
    • if (!res)
    • return (NULL);
    • memcpy(res, str, len);
    • return res;
    • }
    • char *my_strdup_2(const char *str) {
    • const size_t len = strlen(str);
    • char *const res = malloc(len); // <- BUG
    • memcpy(res, str, len + 1);
    • const size_t len = strlen(str) + 1;
    • char * const res = malloc(len);
    • if (!res)
    • return (NULL);
    • memcpy(res, str, len);
    • return res;
    • }