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

ref. The Genuine Sieve of Eratosthenes

Return primes as an infinite stream of prime numbers.

Encodings

Use numEncoding: BinaryScott, and export the deconstructors head, tail for the stream.


Text below is not for the kumite, just testing with language-specific markup.

Combinators

B  = \ f g x . f (g x)
C  = \ f x y . f y x
I  = \ x . x
K  = \ x _ . x
KI = \ _ x . x
S  = \ f g x . f x (g x)
Y  = \ f . ( \ x . f (x x) ) ( \ x . f (x x) )

Booleans

False = K
True = KI

False = \ f t . f
True  = \ f t . t

Lists may be defined as

< x y z > = \ c n . c x (c y (c z n))
# JohanWiltink

# primes
# according to The Genuine Sieve of Erathosthenes

#import combinators.lc
B  = \ f g x . f (g x)
C  = \ f x y . f y x
I  = \ x . x
K  = \ x _ . x
KI = \ _ x . x
S  = \ f g x . f x (g x)
T  = \ x f . f x
V  = \ x y f . f x y

#import ordering.lc
LT = \ lt _eq _gt . lt
EQ = \ _lt eq _gt . eq
GT = \ _lt _eq gt . gt

#import boolean.lc
False = \ false _true . false
True  = \ _false true . true

# data Number = End | Even Number | Odd Number

# zero :: Int
zero = \ end _even _odd . end

# shiftR0,shiftR1 :: Int -> Int
shiftR0 = \ n . \ _end even _odd . even n # mind that a shiftR in LE is a multiplication
shiftR1 = \ n . \ _end _even odd . odd  n # mind that a shiftR in LE is a multiplication

# instance Eq

# is-zero :: Int -> Bool
is-zero = \ n . n True (K False) (K False)

# unpad :: Int -> Int
unpad = \ n . n zero ( \ z . ( \ unpad-z . is-zero unpad-z (shiftR0 unpad-z) zero ) (unpad z) ) (B shiftR1 unpad)

# instance Enum

# succ,pred :: Int -> Int
succ = \ n . n (shiftR1 zero) shiftR1 (B shiftR0 succ)
go = \ prefix n . n zero
                    (go (B prefix shiftR1))
                    ( \ z . z (prefix z) (K (prefix (shiftR0 z))) (K (prefix (shiftR0 z))) )
pred = go I

# instance Ord

# compare :: Int -> Int -> Ordering
compare = \ m n . m (n EQ (K LT) (K LT))
                    ( \ zm . n GT (compare zm) ( \ zn . compare zm zn LT LT GT ) )
                    ( \ zm . n GT ( \ zn . compare zm zn LT GT GT ) (compare zm) )
# eq,gt :: Int -> Int -> Bool
eq = \ m n . compare m n False True  False
gt = \ m n . compare m n False False True

# instance Num

# add,mul,sub :: Int -> Int -> Int
add = \ m n . m n
                ( \ zm . n (shiftR0 zm) (B shiftR0 (add zm)) (B shiftR1 (add zm)) )
                ( \ zm . n (shiftR1 zm) (B shiftR1 (add zm)) (B shiftR0 (B succ (add zm))) )

mul = \ m n . m m
              ( \ zm . n n
                         ( \ zn . shiftR0 (shiftR0 (mul zm zn)) )
                         ( \ zn . shiftR0 (mul zm (shiftR1 zn)) )
              )
              ( \ zm . n n
                         ( \ zn . shiftR0 (mul (shiftR1 zm) zn) )
                         ( \ zn . add (shiftR1 zn) (shiftR0 (mul zm (shiftR1 zn))) )
              )
unsafe-sub = \ m n . m zero
                       ( \ zm . n (shiftR0 zm) (B shiftR0 (unsafe-sub zm)) (B shiftR1 (B pred (unsafe-sub zm))) )
                       ( \ zm . n (shiftR1 zm) (B shiftR1 (unsafe-sub zm)) (B shiftR0 (unsafe-sub zm)) )
sub = \ m n . gt m n zero (unpad (unsafe-sub m n)) # needs explicit unpad or will litter padding

# data Pair a b :: Pair a b

# pair :: a -> b -> Pair a b
pair = \ x y . \ pair . pair x y

# fst :: Pair a b -> a
fst = \ xy . xy \ x _y . x

# snd :: Pair a b -> b
snd = \ xy . xy \ _x y . y

# data Stream a :: Cons a (Stream a)

# cons :: a -> Stream a -> Stream a
cons = \ x xs . \ cons . cons x xs

# head :: Stream a -> a
head = \ xs . xs \ x _xs . x

# tail :: Stream a -> Stream a
tail = \ xs . xs \ _x xs . xs

# map :: (a -> b) -> Stream a -> Stream b
map = \ fn xs . xs \ x xs . cons (fn x) (map fn xs)

# iterate :: (a -> a) -> a -> Stream a
iterate = \ fn x . cons x (iterate fn (fn x))

# le :: Stream a -> Stream a -> Bool
le = \ m n . compare (head m) (head n) True True False # comparing on later elements is not necessary for this task

# data Set a = Nil | Branch a (Set a) (Set a)

# empty :: Set a
empty = \ nil _branch . nil

# branch :: a -> Set a -> Set a -> Set a
branch = \ x left right . \ _nil branch . branch x left right

# insert :: (Ord a) => a -> Set a -> Set a
insert = \ x set .
             set
               (branch x empty empty)
               ( \ y left right .
                     le x y
                       (branch y left (insert x right))
                       (branch y (insert x left) right)
               )

# findMin :: (Partial) => Set a -> a
find-min = \ set . set ()
           \ x left right .
               left x ( \ _ _ _ . find-min left )

# minView :: (Partial) => Set a -> (a,Set a)
min-view = \ set . set ()
           \ x left right .
               left
                 (pair x right)
                 ( \ _ _ _ . ( \ unpair . unpair \ y left' . pair y (branch x left' right) ) (min-view left) )

# insertPrime :: Stream Int -> Set (Stream Int) -> Set (Stream Int)
insert-prime = \ candidates . candidates
               \ prime _ .
                   insert (map (mul prime) candidates)

# adjust :: Int -> Set (Stream Int) -> Set (Stream Int)
adjust = \ x table .
  ( \ unpair . unpair
    \ uncons table' . uncons
    \ n ns .
        eq n x
          table
          (adjust x (insert ns table'))
  )
  (min-view table)

# sieve :: Set (Stream Int) -> Stream Int -> Stream Int
sieve = \ table xxs . xxs
        \ x xs .
            ( \ uncons . uncons
              \ n _ .
                  eq n x
                    (cons x (sieve (insert-prime xxs table) xs))
                    (sieve (adjust x table) xs)
            )
            (find-min table)

# setupSieve :: Stream Int -> Stream Int
setup-sieve = \ xxs . xxs
              \ x xs .
                 cons x (sieve (insert-prime xxs empty) xs)

# primes :: Stream Int
primes = cons 2 (setup-sieve (iterate (add 2) 3))

Create a function that checks if a number n is divisible by two numbers x AND y. All inputs are positive, non-zero digits.

Examples:

  1. n = 3, x = 1, y = 3 => true because 3 is divisible by 1 and 3
  2. n = 12, x = 2, y = 6 => true because 12 is divisible by 2 and 6
  3. n = 100, x = 5, y = 3 => false because 100 is not divisible by 3
  4. n = 12, x = 7, y = 5 => false because 12 is neither divisible by 7 nor 5
function isDivisible(n, x, y) {
  if (n % x === 0 && n % y === 0) {
    return true
  } else {
    return false
  }
}

Write a function called power which takes in a base and an exponent. If the exponent is 0, return 1.

Sample:

console.log(power(2, 4)); // 16
console.log(power(2, 3)); // 8
console.log(power(2, 2)); // 4 
console.log(power(2, 1)); // 2
console.log(power(2, 0)); // 1
function power(num,exp){
  if(exp === 0){
    return 1;
  }
  if(exp % 2 === 0){
    let half = Math.floor(exp/2)
    return power(num, half) * power(num, half);
  }else{
    let half = Math.floor((exp-1)/2)
    return num * power(num, half) * power(num, half);
  }
  
}

Write a function that returns the factorial of a number. As a quick refresher, a factorial of a number is the result of that number multiplied by the number before it, and the number before that number, and so on, until you reach 1. The factorial of 1 is just 1.

Sample:

factorial(5); // 5 * 4 * 3 * 2 * 1 === 120

function factorial(num){
  if(num === 1){
    return 1;
  }
  
  return num * factorial(num - 1)
}
Fundamentals

The YouTube video that inspired this: https://www.youtube.com/watch?v=vKlVNFOHJ9I

When a number n is inputted, the function produces a number where its digits count up to n and back down to one.

Here are some examples of how the function should function.

1 --> 1
2 --> 121
3 -- > 12321

Notice how there is only one n in the integer.

For situations where n > 9, some numbers may be two digits instead of one, such as the example here:

10 --> 12345678910987654321

All numbers will be integers greater than zero.

def numberprint(x):
    accending = list(range(1, x + 1))
    descending = list(range(x-1, 0, -1))
    newlist = accending + descending
    strings = [str(integer) for integer in newlist]
    a_string = "".join(strings)
    an_integer = int(a_string)
    return an_integer
namespace Test {
  public class Test {
    public string a;
    public string b = null;
  }
}

Make upper case

function upperCase(s) {
  //JUST DO IT
}
k0st1xFailed Tests

fizzbuzz rus

Начинающий произносит число «1», и каждый следующий игрок прибавляет к предыдущему значению единицу. Когда число делится на три оно заменяется на fizz, если число делится на пять, то произносится buzz. Числа, делящиеся на три и пять одновременно заменяются на fizz buzz. Сделавший ошибку игрок исключается из игры.

Типичная партия в fizz buzz выглядит так:

1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, Fizz Buzz, 16, 17, Fizz, 19, Buzz, Fizz, 22, 23, Fizz, Buzz, 26, Fizz, 28, 29, Fizz Buzz, 31, 32, Fizz, 34, Buzz, Fizz, ...
class Program {
  public static string fizzbuzz(int value) {
    return "test me";
  }
}
a = lambda : {k: chr(v) for (k, v) in enumerate(range(97, 123), start=0)}
import java.util.Scanner;

public class QurterOfMonth {
    static int month ;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("enter the month");
        int month = scanner.nextInt();
        if (month <= 3) System.out.println("First Qurter");
        else if (month >= 4 && month<=6) System.out.println("Second Qurter");
        else if (month >= 6 && month <= 9) System.out.println("Third Qurter");
        else if (month >= 9 && month <= 12) System.out.println("Forth Qurter");
    }
}