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
  • #include <array>
    
    template <std::size_t L>
    long
    add_arr(std::array<int, L> arr)
    {
      long result = 0;
      for (int i : arr) result += i;
      return result;
    }
    
    template long add_arr(std::array<int, 9> arr);
    • #include <array>
    • template <std::size_t L>
    • long
    • add_arr(const unsigned long len, const int arr[len])
    • add_arr(std::array<int, L> arr)
    • {
    • long result = 0;
    • for
    • (
    • unsigned long i = 0;
    • i < len;
    • result += arr[i++]
    • );
    • for (int i : arr) result += i;
    • return result;
    • }
    • }
    • template long add_arr(std::array<int, 9> arr);

no math except subtraction :)

Code
Diff
  • from sys import getsizeof as size
    def odd_even(n):
        def odd():
            nonlocal n
            while n>1:
                n-=2
        odd()
        return size(n)==24
    • import random
    • from sys import getsizeof as size
    • def odd_even(n):
    • hashmap = {
    • 1: 'True',
    • 2: 'False'
    • }
    • maphash = {
    • 'True': 1,
    • 'False': 0
    • }
    • ebb = random.randint(1000000000000, 9999999999999)
    • flow = random.randint(1000000000000, 9999999999999)
    • power_ball = ebb * flow
    • while True:
    • if power_ball == 1:
    • break
    • for i in range(power_ball):
    • while power_ball:
    • if ebb >= True and flow <= False:
    • return hashmap.get(2)
    • else:
    • def beta(x):
    • if ebb == pow(flow, 2) and ebb == 1:
    • return hashmap.get(1)
    • else:
    • return (((x * 3) + 6) // 3) - x
    • def gamma(y):
    • if ebb == flow and flow < pow(ebb, flow):
    • return hashmap.get(1)
    • elif flow == ebb and beta(flow) > ebb:
    • return hashmap.get(2)
    • else:
    • return ((y * 2 + 6) // 2) - y
    • def yin(x):
    • for i in range(power_ball):
    • if yang(ebb) > gamma(flow):
    • return hashmap.get(2)
    • elif beta(flow) == yang(gamma(flow)):
    • return hashmap.get(1)
    • else:
    • while True:
    • if x <= 1:
    • break
    • elif x % beta(flow) == yang(ebb) - 1:
    • x //= sum([1, True])
    • elif beta(flow) == beta(ebb) + 1:
    • return hashmap.get(1)
    • elif ord('c') + ord('o') + ord('d') + ord('e') == beta(gamma(flow)):
    • return hashmap.get(2)
    • else:
    • x *= gamma(ebb + flow)
    • x += yang(flow)
    • return x
    • def yang(x):
    • omega = 777
    • while omega:
    • if gamma(ebb) + gamma(flow) == beta(ebb + flow):
    • return hashmap.get(2)
    • else:
    • while True:
    • if x <= gamma(ebb) - beta(flow):
    • break
    • elif x % 0o144 - 0x62 == 1:
    • x *= gamma(flow)
    • x += True
    • else:
    • x //= gamma(ebb) - 1
    • omega -= 1
    • return x
    • power_ball -= 1
    • tik = yin(ebb) + n
    • tok = yang(flow) - n
    • if n % (tik + tok) == (gamma(flow) - beta(ebb)) - 1:
    • return maphash[hashmap.get(1)]
    • else:
    • return maphash[hashmap.get(2)]
    • def odd():
    • nonlocal n
    • while n>1:
    • n-=2
    • odd()
    • return size(n)==24
Strings
Big Integers

more test cases
added logs

Code
Diff
  • __uint128_t solution(char* str1, char* str2) {
      __uint128_t result = 0;
      
      for (unsigned long i = 0; i < 7; ++i) {
        result +=
          (((__uint128_t) str1[i]) << (8*(i + 0))) +
          (((__uint128_t) str2[i]) << (8*(i + 8)));
      }
      
      return result;
    }
    • __uint128_t solution(char* str1, char* str2) {
    • __uint128_t result = 0;
    • for (unsigned long i = 0; i < 7; ++i) {
    • result +=
    • (((__uint128_t) str1[i]) << (8*i)) +
    • (((__uint128_t) str1[i]) << (8*(i + 0))) +
    • (((__uint128_t) str2[i]) << (8*(i + 8)));
    • }
    • return result;
    • }

A while loop does all the work of iterating every digit in n; first it asks if the digit on the right is 3, and if it is it stops looping. If it is not, and n is still greater than 0, it divides n by 10. If we hit 0 for n we have iterated the entire number, and the loop stops now if it didn't already. This means we just have to check if n is greater than 0 - if it is we stopped early because we found a 3.

Code
Diff
  • using System;
    
    public class Kumite {
      public static bool IsThree(int n) {
        while(n%10!=3&&n>0)n/=10;
        return n>0;
      }
    }
    • using System;
    • public class Kumite {
    • public static bool IsThree(int number) {
    • var digitToSearch = 3;
    • var amountOfDigits = (int)Math.Log10(number);
    • for (int i = 0; i <= amountOfDigits; i++)
    • {
    • var divisor = (int)Math.Pow(10, i);
    • var truncate = number / divisor;
    • var digit = truncate % 10;
    • if (digit == digitToSearch)
    • {
    • return true;
    • }
    • }
    • return false;
    • public static bool IsThree(int n) {
    • while(n%10!=3&&n>0)n/=10;
    • return n>0;
    • }
    • }

noooooooo pyramids again

Code
Diff
  • def return_hundred():
        l = ['a', False, 'капибара', 1000-7 , "eygwqfgeqwte7", True, 100, 100.000000000000000001, "100", 10 ** 10, "xyz"]
        for i in l:
            if i == 100:
                return i
                break;
    
            
    • def return_hundred():
    • def ten():
    • def one():
    • one=lambda a,b,c: 1
    • return one("bad","coding","practice")
    • ten=sum(one() for _ in range(10))
    • return ten
    • return ten()*ten()
    • l = ['a', False, 'капибара', 1000-7 , "eygwqfgeqwte7", True, 100, 100.000000000000000001, "100", 10 ** 10, "xyz"]
    • for i in l:
    • if i == 100:
    • return i
    • break;
Algorithms
Code
Diff
  • use std::io::{Write, Cursor};
    
    fn digits(n: u64) -> usize {
        n.to_string().len()
    }
    • use std::io::{Write, Cursor};
    • fn digits(mut n: u64) -> usize {
    • let mut b = [0u8; 20];
    • let mut c = Cursor::new(&mut b[..]);
    • write!(c, "{}", n).unwrap();
    • c.position() as usize
    • fn digits(n: u64) -> usize {
    • n.to_string().len()
    • }