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.


A container that you access like a sorted container, but only sorts the parts it needs to.
Based off of quicksort, so O(N**2) for a single access.
However, everything only needs to be sorted once, so it is O(N**2+Q) for Q queries.

#include <iostream>
#include <utility>
#include <memory>
#include <vector>

using pii = std::pair<int, int>;

class kata {
    std::vector<std::shared_ptr<pii>> ranges;
    std::vector<int> &data;
    kata(std::vector<int> &in_data)
        : data(in_data)
        , ranges(in_data.size(), std::shared_ptr<pii>(new pii(0, in_data.size())))
    int operator[](int index) {
        for (int x : data) {
            std::cout << x << ' ';
        std::cout << "| " << ranges[index]->first << ' ' << ranges[index]->second << '\n';
        int start = ranges[index]->first;
        int end = ranges[index]->second;
        if (end - start == 1) {
            return data[index];
        int pivot = data[index];
        data[index] = data[end - 1];
        data[end - 1] = pivot;
        std::shared_ptr<pii> lt_pivot(new pii(start, start));
        int p = start;
        for (int i = start; i < end - 1; ++i) {
            if (data[i] < pivot) {
                int temp = data[p];
                data[p] = data[i];
                data[i] = temp;
                ranges[p] = lt_pivot;
        lt_pivot->second = p;
        data[end - 1] = data[p];
        data[p] = pivot;
        ranges[p]->first = p;
        ranges[p]->second = p + 1;
        std::shared_ptr<pii> gt_pivot(new pii(p + 1, end));
        for (int i = p + 1; i < end; ++i) {
            ranges[i] = gt_pivot;
        return this->operator[](index);


Uppercase the first character of each word in a string.
public function caps($c)
        return ucwords($c);
Data Types

In order to understand the everyday hasstle of people that suffer from dislexia my school made us do this activity:

  • replace all the (A's O's E's I's) of a certain phrase with (4's 0's 3's 1's) respectively

and we did it, but it took soooo long, would you write a bit of code that does the work for me?


dislexifier ->

  • input : "Hey Arianna, how u doing?"
  • output : "H3y 4ri4nn4, h0w u d01ng?"

ps.: try to avoid just using .replace(), it will make it more fun.

class Dislexifier
  public static String theDislexifier(String str)
    // TODO: Do your magic here 
    return str.replace("a","4").replace("A","4").replace("o","0").replace("O","0").replace("e","3").replace("E","3").replace("i","1").replace("I","1");

It will get a dictionary and return a list of the keys, all sorted by their corrosponding values in increasing order.

def dict_index(dictionary, value):
    dict_keys = list(dictionary)
    dict_values = list(dictionary.values())
    return dict_keys[dict_values.index(value)]

def dict_sort(dictionary):
    dict_values = list(dictionary.values())
    new_keys = []
    for x in range(len(dictionary)):
        max_value = max(dict_values)
        new_keys.append(dict_index(dictionary, max_value))
    return new_keys

A Python class that converts strings to integers and back.
itos: int-to-string
stoi: string-to-int
Note: Currently broken

def dict_sort(dictionary):
    return sorted(dictionary, key=dictionary.__getitem__)

def convert_to_base(decimal_number, base, digits):
    remainder_stack = []
    while decimal_number > 0:
        remainder = decimal_number % base
        decimal_number = decimal_number // base
    new_digits = []
    while remainder_stack:
    return ''.join(new_digits)
def base_to_dec(string, base, digits):
    num_str = string[::-1]
    num = 0
    for k in range(len(num_str)):
        dig = num_str[k]
        if dig.isdigit():
            dig = int(dig)
            dig = digits.index(dig.lower())-digits.index('a')+10
        num += dig*(base**k)
    return int(num)

class converter:
    def __init__(self, codec=None):
        if codec == None:
            self.codec = ''
            self.codec = codec
    def fit(self, strings):
        chars = {}
        if type(strings) == list:
            string = '\n'.join(strings)
            string = strings
        for x in string:
            if x not in chars:
                chars[x] = string.count(x)
        self.codec = ''.join(dict_sort(chars))
    def stoi(self, string):
        return base_to_dec(string, len(self.codec), self.codec)
    def itos(self, number):
        return convert_to_base(number, len(self.codec), self.codec)

You need to write a function that checks if a number is prime or not.


prime_checker(100) => False
prime_checker(5) => True
prime_checker(709) => True

So if the given number is prime you need to return True, and if not you need to return False

Hint: Probably you will need to import math:

import math
import math
def prime_checker(n):
    if n == 1:
        return False
    max_divisor = math.floor(math.sqrt(n))
    for d in range(2, 1 + max_divisor):
        if n % d == 0:
            return False
    return True

There is a vector class consisting of 3 coordinates and a segment class consisting of 2 vectors. The task is to write a function that finds the intersection of two segments, if it exists.

The idea of solving the problem is to find the minimum distance between the segments, and if it is less than a certain specified value, then we can assume that the segments intersect.

float scalar_product(Vector3D a, Vector3D b)
    return (a.get_x()*b.get_x() + a.get_y()*b.get_y() + a.get_z()*b.get_z());

Vector3D intersec(Segment a, Segment b)
    Segment seg;
    float t1 = 0, t2 = 0, t = 0;
    t1+= scalar_product(a.start-b.start, b.end-b.start)*scalar_product(b.end-b.start, a.end-a.start);
    t1-= scalar_product(a.start-b.start, a.end-a.start)*scalar_product(b.end-b.start, b.end-b.start);
    t2+= scalar_product(a.end-a.start, a.end-a.start)*scalar_product(b.end-b.start, b.end-b.start);
    t2-= scalar_product(a.end-a.start, b.end-b.start)*scalar_product(b.end-b.start, a.end-a.start);
    t = t1/t2;

    float u1 = 0, u2 = 0;
    u1+= (scalar_product(a.start-b.start, b.end-b.start));
    u1+= t*scalar_product(a.end-a.start, b.end-b.start);
    u2 = scalar_product(b.end-b.start, b.end-b.start);

    seg.end = a.start + (a.end - a.start)*t;
    seg.start = b.start + (b.end - b.start)*u1/u2;
    Vector3D tmp = seg.end - seg.start;
    Vector3D close_point = (seg.end + seg.start) / 2;

        if (scalar_product(close_point - a.start, a.end - a.start) < 0 ||
            scalar_product(close_point - a.end, a.start - a.end) < 0)
            throw std::string("point outside first segment bound");
        if (scalar_product(close_point - b.start, b.end - b.start) < 0 ||
            scalar_product(close_point - b.end, b.start - b.end) < 0)
            throw std::string("point outside second segment boundaries");
        if ((scalar_product(tmp, tmp) - 0.001) > 0)
            throw std::string("no intersection point");
    catch(const std::string& ex)
        std::cerr << ex << '\n';
    return close_point;

Return a string that says "Test"

let rTest = ()=>"Test"

It has been decided that I like Ruby.

require "net/http"
require "nokogiri"

langs = {}
langs.default = 0

(1..10).each { |page| 
    .xpath("//div[contains(@class, 'flex flex-row items-center mb-4')]")
    .each { |node| 
      lang = node.xpath("string(./div[contains(@class, "\
                      "'icon-container mb-0 bg-gray-200 dark:bg-k-20')]"\
      langs[lang[10...lang.length - 1]] += 1

puts langs
def factorial(n: int) -> int:
    """Returns factorial of a non-negative integer."""
    return 1 if n <= 0 else eval('*'.join([str(i) for i in range(1, n + 1)]))