Begin a new Kumite
Search
About
  • Filter by Language:
  • 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.

Given two strings, the task is to check whether these strings are meta strings or not. Meta strings are the strings which can be made equal by exactly one swap in any of the strings. Equal string are considered here as Meta strings.

func areMetaStrings(_ str1: String, _ str2: String) -> Bool {
    return str1.lowercased().sorted() == str2.lowercased().sorted()
}
Code
Diff
  • package solution
    
    fun tribonacci(n: Int, signature: Triple<Int, Int, Int> = Triple(1, 1, 1)) =
        generateSequence(signature) { Triple(it.second, it.third, it.first + it.second + it.third) }
            .map { it.first }
            .take(n)
            .toList()
    
  • 1-fun tribonacci(signature: DoubleArray, n: Int) = generateSequence(Triple(signature[0], signature[1], signature[2])) {
    2- Triple(it.second, it.third, it.first + it.second + it.third) }
    1+package solution
    2+
    3+fun tribonacci(n: Int, signature: Triple<Int, Int, Int> = Triple(1, 1, 1)) =
    4+ generateSequence(signature) { Triple(it.second, it.third, it.first + it.second + it.third) }
    33 .map { it.first }
    44 .take(n)
    55 .toList()
    6- .toDoubleArray()
    7-
    8-
    9-
    10-fun main() {
    11- val array = doubleArrayOf(1.0,1.0,1.0)
    12- tribonacci(array, 10)
    13-}
Code
Diff
  • const AbbreviateTwoWords = s => {
      const [first, middle, ...rest] = s.split(' ')
      return `${first.slice(0,1)}.${middle.slice(0,1)}. ${rest}`
    }
  • 1-public class AbbreviateTwoWords {
    2-
    3- public static String abbrevName(String name) {
    4- String[] names = name.split(" ");
    5- return (names[0].charAt(0) + "." + names[1].charAt(0)).toUpperCase();
    6- }
    1+const AbbreviateTwoWords = s => {
    2+ const [first, middle, ...rest] = s.split(' ')
    3+ return `${first.slice(0,1)}.${middle.slice(0,1)}. ${rest}`
    77 }
Code
Diff
  • const rot13 = s => s.replace(/[a-z]/g, m => String.fromCharCode(97+(m.charCodeAt(0)-97+13)%26))
  • 1-def rot13(s):
    2- return rot.encode(s,"rot_13")
    1+const rot13 = s => s.replace(/[a-z]/g, m => String.fromCharCode(97+(m.charCodeAt(0)-97+13)%26))
Code
Diff
  • const decrypt = (s,d,a='ABCDEFGHIJKLMNOPQRSTUVWXYZ') => s.replace(/[A-Z]/g, m => a[(a.indexOf(m)+26-d)%26])
  • 1-def decrypt(code,amount):
    2- #place code here
    3- let="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    4- word = ""
    5- x=0
    6- for c in range(0,len(code)):
    7- for i in range (0,len(let)):
    8- if code[c] == " ":
    9- word+=" "
    10- break
    11- elif code[c] == let[i]:
    12- x=i
    13- x-=amount
    14- if x < 0:
    15- x+=26
    16- word+=let[x]
    17- break
    18- return word
    1+const decrypt = (s,d,a='ABCDEFGHIJKLMNOPQRSTUVWXYZ') => s.replace(/[A-Z]/g, m => a[(a.indexOf(m)+26-d)%26])

wrvcqwre

using System;


namespace Interpreter.Cata
{
    public static class FunctionalExtensions
    {

        public static Reader<Env, T1> App<Env, T, T1>(this Reader<Env, Func<T, T1>> @this, Reader<Env, T> fa)
            => new Reader<Env, T1>(env => { return @this.Map(f => fa.Map(f).Run(env)).Run(env); });



        public static T1 Eval<T, T1>(this Expr<T> @this,
            (Func<T1, T1, T1> add, Func<T1, T1, T1> sub, Func<T, T1> val) algebra)
            =>
            @this.MatchWith(pattern: (
                   add: (x, y) => algebra.add(x.Eval(algebra), y.Eval(algebra)),
                   sub: (x, y) => algebra.sub(x.Eval(algebra), y.Eval(algebra)),
                   val: v => algebra.val(v)
            ));

    }
    public abstract class Expr<T>
    {
        public abstract T1 MatchWith<T1>((Func<Expr<T>, Expr<T>, T1> add, Func<Expr<T>, Expr<T>, T1> sub, Func<T, T1> val) pattern);
    }
    public class ValExpr<T> : Expr<T>
    {
        public ValExpr(T x) { X = x; }
        public T X { get; }
        public override T1 MatchWith<T1>((Func<Expr<T>, Expr<T>, T1> add, Func<Expr<T>, Expr<T>, T1> sub, Func<T, T1> val) pattern)
                 => pattern.val(X);
    }
    public class AddExpr<T> : Expr<T>
    {
        public AddExpr(Expr<T> x, Expr<T> y) { X = x; Y = y; }

        public Expr<T> X { get; }
        public Expr<T> Y { get; }

        public override T1 MatchWith<T1>(
            (Func<Expr<T>, Expr<T>, T1> add,
            Func<Expr<T>, Expr<T>, T1> sub,
            Func<T, T1> val) pattern)
             => pattern.add(X, Y);
    }
    public class SubExpr<T> : Expr<T>
    {
        public SubExpr(Expr<T> x, Expr<T> y) { X = x; Y = y; }

        public Expr<T> X { get; }
        public Expr<T> Y { get; }

        public override T1 MatchWith<T1>((Func<Expr<T>, Expr<T>, T1> add,
             Func<Expr<T>, Expr<T>, T1> sub,
            Func<T, T1> val) pattern)
             => pattern.sub(X, Y);
    }
    public class Reader<Env, T>
    {
        public Func<Env, T> Fn { get; set; }
        public Reader(Func<Env, T> fn) => Fn = fn;
        public Reader<Env, T1> Map<T1>(Func<T, T1> f) => new Reader<Env, T1>((env) => f(Fn(env)));
        public T Run(Env env) => Fn(env);
    }
    public class Config
    {
        public string Name { get; set; }
    }

    public class Demo
    {
        public static void Run()
        {
            var expression = new SubExpr<int>(new AddExpr<int>(new ValExpr<int>(2), new ValExpr<int>(2)), new ValExpr<int>(2));

            var result = expression.Eval(algebra: (
                    add: (x, y) => x + y,
                    sub: (x, y) => x + y,
                    val: v => v)
                );

        }
    }



}

Write a function that converts a base 10 number and returns binary (base 2).

Binary is consisted of zeros and ones only, and those make up the binary number.

Suppose that place value works the same.

func binaryConverter(_ input: Int) -> Int {
  //Your Code Here
  return input
}