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.


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)]))

Given a projectile speed s in m/s, the angle of the initial velocity beta in degrees, and the height of the origin y, calculate the time until the projectile arrives at the ground (y=0).

Further note:

  • Assume there is no drag.
  • 0 <= s, y <= 1000, 0 <= beta <= 90,
  • The time has to be accurate to three decimals.
  • Use 9.81 m/s^2 as the gravitional acceleration.
import math

def calc_time_of_impact(speed, angle, origin_y):

    x_value = 0
    y_value = 0
    time = 0.0001

    def x_formula(t): return speed * t * \
        math.cos(angle * math.pi / 180)

    def y_formula(t): return speed * t * \
        math.sin(angle * math.pi / 180) - 9.81/2*t*t

    while y_value >= -origin_y:
        x_value = x_formula(time)
        y_value = y_formula(time)
        time += 0.0001

    return time

Ruby sometimes feels like the least functional possible language.
I don't fully understand what's going on in that first line, I figured it out after having a nice chat with irb syntax errors about what it expects of me.


def a(x)
  puts "a #{x}"
  8 / x

def b(x)
  puts "b #{x}"
  2 * x

def c(x)
  puts "c #{x}"
  2 + x

puts a b c 2


let a x y z =
  print_endline "a";
  8 / x y z

let b y z =
  print_endline "b";
  2 * y z

let c z =
  print_endline "c";
  2 + z

print_endline @@ string_of_int @@ a b c 2

Mathmatical simplification of sin and cosine? Only 2 decimal places of accuracy required.

import math

def CirclePoint(angle):
    return (math.cos(angle), math.sin(angle))