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
#debug

#import combinators.lc
B = \ f g x . f (g x)
I = \ x . x
K = \ x _ . x
T = \ x f . f x

#import binary-scott-number.lc
#  0 =       \ end _even _odd . end
Bit0 = \ n . \ _end even _odd . even n
Bit1 = \ n . \ _end _even odd . odd  n
shift  = \ n . n 0 I I
dbl = \ n . n 0 (K (Bit0 n)) (K (Bit0 n))
succ = \ n . n 1 Bit1 (B Bit0 succ)
pred = \ n . n 0 (B Bit1 pred) dbl
add = \ m n . m n
                ( \ zm . n m (B Bit0 (add zm)) (B Bit1 (add zm)) )
                ( \ zm . n m (B Bit1 (add zm)) (B Bit0 (B succ (add zm))) )
mul = \ m n . m 0
                ( \ zm . n 0
                           ( \ zn . Bit0 (Bit0 (mul zm zn)) )
                           ( \ _z . Bit0 (mul zm n) )
                )
                ( \ zm . n 0
                           ( \ zn . Bit0 (mul m zn) )
                           ( \ zn . Bit1 (add (dbl (mul zm zn)) (add zm zn)) )
                )

#import scott-tree.lc
Tree = \ x left right . \ tree . tree x left right # Tree = Tree Number Tree Tree
map = \ fn tree . tree \ x left right . Tree (fn x) (map fn left) (map fn right)
index = \ tree i . tree \ x left right . i x (B (index right) pred) (index left)

tree = Tree 1 (map Bit0 tree) (map Bit1 tree)
memo = \ fn . index (map (B fn pred) tree)

# fibonacci :: Number -> Number
fibonacci = memo \ n .
  T (shift (succ n))      \  n' .
  T (fibonacci n')        \ fn  .
  T (fibonacci (pred n')) \ fn' .
  n 0                                            # n == 0
   (K (mul fn (add fn (Bit0 fn'))))              # even n
   ( \ z . z 1                                   # n == 1
            (K (add (mul fn fn) (mul fn' fn')))  # odd n
            (K (add (mul fn fn) (mul fn' fn')))  # odd n
   )
function angka($a , $b) {
    if ($a != 0 || $b != 0){
      echo "ada angka. \n";
        if( $a > 10 || $b > 10 ){
          echo "angka lebih dari 10. \n";
          if($a < $b) {
            echo "a lebih besar dari b. \n";
          } else {
            echo "b lebih besar dari a. \n";
          }
        } else {
          echo "angka kurang dari 10. \n";
        }
    } else{
      echo "tidak ada angka.";
    }
}

angka(11,11);
ThuNX117Failed Tests

Summary

create summary

function  sum(a,b){
  return a+b
}

Should return sum of two elements

def sum(i1, i2)
  i1 + i2
end
import javax.swing.JOptionPane;
public class Loop{
  public static void main(String[] args){
    while(1!=0){
      JOptionPane.showMessageDialog(null, "Annoying");
    }
  }
}
Linear Algebra
Mathematics
Algebra
Matrix

Given a matrix M and a vector v, linearly transform the vector using the matrix.

ex:

const M = [[2,0],[0,2]]
const v = [1,1]
transform(M, v); // [2,2]

More examples:

const M = [[2,2],[3,2]]
const v = [1,1]
transform(M, v); // [5,4]
const M = [[2,0],[0,2]]
const v = [2,3]
transform(M, v); // [4,6]
const M = [[2,5],[0,3]]
const v = [1,2]
transform(M, v); // [5,5]
function transpose(A) {
  let arrs = []
  /*
  |4 5| -> |4 6|
  |6 7|    |5 7|
  [[4,5], [6,7]] -> [[4,6], [5,7]]
  */
  A.forEach((x,i)=>{
    x.forEach((v,i2)=>{
      if(!arrs[i2]){
        arrs[i2] = [v]
      }else arrs[i2].push(v)
    })
  })
  return arrs
}

function scale(v,a) {
let ret = []
v.forEach((x,i)=>{
  ret.push(x*a)
})
return ret
}

function transform(M, a) {
let m = transpose(M)
let ae = []
a.forEach((x,i)=>{
  ae.push(scale(m[i], x))
})
return sum(ae)
}

function sum(v) {
  let s = v[0]
  v.forEach((x,i)=>{
    if(i == 0) return
    x.forEach((y)=>{
      s[i] += y
    })
})
  return s
}

обычный простой калькулятор, но с использованием степеней

#include <iostream>

int main()
{
  string operator = "+";
  int a = 5, b = 6;
  cin >> a >> opearator >> b;
  //5 + 6 = 11
}

жлджлджлд

def solution(s):
    newStr = ''
    for i in s:
        newStr += i
        if i.isupper() == True:
            newStr = newStr[:-1]
            newStr += ' ' + i
    return newStr
const board = [];
let player = "X";

for (let i = 0; i < 3; i++) {
  board.push([" ", " ", " "]);
}

const printBoard = () => {
  console.log(` ${board[0][0]} | ${board[0][1]} | ${board[0][2]} `);
  console.log("---+---+---");
  console.log(` ${board[1][0]} | ${board[1][1]} | ${board[1][2]} `);
  console.log("---+---+---");
  console.log(` ${board[2][0]} | ${board[2][1]} | ${board[2][2]} `);
};

const makeMove = (row, col) => {
  board[row][col] = player;
  player = player === "X" ? "O" : "X";
};

const isWin = () => {
  for (let i = 0; i < 3; i++) {
    if (board[i][0] === board[i][1] && board[i][1] === board[i][2] && board[i][0] !== " ") {
      return true;
    }
    if (board[0][i] === board[1][i] && board[1][i] === board[2][i] && board[0][i] !== " ") {
      return true;
    }
  }
  if (board[0][0] === board[1][1] && board[1][1] === board[2][2] && board[0][0] !== " ") {
    return true;
  }
  if (board[0][2] === board[1][1] && board[1][1] === board[2][0] && board[0][2] !== " ") {
    return true;
  }
  return false;
};

printBoard();
makeMove(0, 0);
printBoard();
makeMove(1, 1);
printBoard();
makeMove(2, 2);
printBoard();
console.log(isWin());

You're an author on CW.
Here is an 2D array. Pass it to user's function, and then receive it.
To determine whether array is modified.
Returns true if modified. Otherwise returns false.

var count=0
const dontTouchMyArray=(array,usersFunction)=>{
  console.log("array:",array)
  /*
  var myArr=array.slice(),myArrs=array.map(x=>x.slice())
  var userArr=usersFunction(array)
  console.log(myArr)
  console.log(myArrs)
  console.log(userArr)
  */
  
  /* Can you write a good solution heer? */
  
  return ++count<12
}