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.

Code
Diff
  • #lang racket
    
    (provide factorial)
    
    (define (factorial n)
      (apply * (inclusive-range 2 n)))
    
    • #lang racket
    • (provide factorial)
    • (define (factorial n)
    • (apply * (range 2 (add1 n))))
    • (apply * (inclusive-range 2 n)))
Code
Diff
  • class wallet:
        def __init__(self, owner):
            self.owner = owner
            self.balance = 0
        def add_money(self, amount):
            self.balance += amount
        def spend_money(self, amount):
            if self.balance <= amount:
                self.balance -= amount
        def check_balance(self):
            return self.balance
        def display_info(self):
            print(f" the owner: {self.owner} the balance: {self.balance}")
            
            
            
        
                                                   
    
    • class bankaccount:
    • class wallet:
    • def __init__(self, owner):
    • self.owner = owner
    • self.balance = 0
    • def deposit(self, amount):
    • def add_money(self, amount):
    • self.balance += amount
    • def withdraw(self, amount):
    • if amount <= self.balance:
    • def spend_money(self, amount):
    • if self.balance <= amount:
    • self.balance -= amount
    • else:
    • print("insifficient funds")
    • def check_balance(self):
    • return self.balance
    • def display_balance(self):
    • print(f"the owner: {self.owner} the balance: {self.balance}")
    • def display_info(self):
    • print(f" the owner: {self.owner} the balance: {self.balance}")
Code
Diff
  • module Example (fib) where
    
    fibonacci :: [Integer]
    fibonacci = 0 : scanl (+) 1 fibonacci
    
    fib :: Int -> Integer
    fib = (!!) fibonacci
    • module Example (fib,fibonacci) where
    • type RAList a = [ ( Int, Tree a ) ]
    • data Tree a = Empty | Node { here :: a, left, right :: Tree a } deriving ()
    • nil :: RAList a
    • nil = []
    • cons :: a -> RAList a -> RAList a
    • cons x ( (size0,tree0) : (size1,tree1) : trees ) | size0 == size1 = ( 1 + size0 + size1, Node x tree0 tree1 ) : trees
    • cons x trees = (1,Node x Empty Empty) : trees
    • fromListN :: Int -> [a] -> RAList a
    • fromListN n = foldr cons nil . take n
    • (!) :: RAList a -> Int -> a
    • ( (size,tree) : trees ) ! n | n < size = index tree size n | otherwise = trees ! (n - size) where
    • index tree size n | n == 0 = here tree
    • | n+n < size = index (left tree) (size `div` 2) (n-1)
    • | otherwise = index (right tree) (size `div` 2) (n-1 - size `div` 2)
    • module Example (fib) where
    • fibonacci :: [Integer]
    • fibonacci = 0 : scanl (+) 1 fibonacci
    • fib :: Int -> Integer
    • fib = (!) (fromListN 200_002 fibonacci)
    • fib = (!!) fibonacci
Code
Diff
  • #
    • sum = lambda a, b: sum(a, b)
    • #
Thirdkoopavs.Knyazik20 days agoFailed Tests

Recursive bomb search

Code
Diff
  • /**
     * Creates a box with optional boxes inside
     */
    const box = (code, boxes) => ({ code, ...(boxes ? { boxes } : {}) });
    
    /**
     * Returns a copy of a box with bomb
     */
    function withBomb(box) {
      return { ...box, bomb: true };
    }
    
    /**
     * Finds the bomb in a box
     */
    function pathToBomb(box, path = []) {
      const newPath = [...path, box.code];
    
      if (box.bomb) return newPath;
      if (!Array.isArray(box.boxes)) return [];
      return traverseBoxes(box.boxes, newPath);
    }
    
    /**
     * Finds the bomb in an array of boxes
     */
    function traverseBoxes(boxes, path = []) {
      return boxes.reduce(
        (result, box) => (result.length > 0 ? result : pathToBomb(box, path)),
        []
      );
    }
    
    /**
     * The main function
     */
    function findTheBomb(boxes) {
      if (boxes.length === 0) throw new Error('Empty array');
      return traverseBoxes(boxes).join(' > ');
    }
    
    // Example usage
    /*
    const myBoxes = [
      box('A', [
        box('B', [
          withBomb(box('C'))
        ])
      ])
    ];
    
    console.log(findTheBomb(myBoxes)); // "A > B > C"
    */
    
    • export interface Box {
    • code: string
    • bomb?: boolean
    • boxes?: Box[]
    • }
    • /**
    • * Creates a box with optional boxes inside
    • */
    • export const box = (code: string, boxes?: Box[]): Box => ({ code, ...( boxes ? { boxes } : {} )});
    • const box = (code, boxes) => ({ code, ...(boxes ? { boxes } : {}) });
    • /**
    • * Returns a copy of a box with bomb
    • */
    • export function withBomb(box: Box) {
    • return { ...box, bomb: true }
    • function withBomb(box) {
    • return { ...box, bomb: true };
    • }
    • /**
    • * Finds the bomb in a box
    • */
    • export function pathToBomb(box: Box, path: string[] = []): string[] {
    • const newPath = [...path, box.code]
    • if (box.bomb) return newPath
    • if (!Array.isArray(box.boxes)) return []
    • return traverseBoxes(box.boxes, newPath)
    • }
    • function pathToBomb(box, path = []) {
    • const newPath = [...path, box.code];
    • if (box.bomb) return newPath;
    • if (!Array.isArray(box.boxes)) return [];
    • return traverseBoxes(box.boxes, newPath);
    • }
    • /**
    • * Finds the bomb in an array of boxes
    • */
    • export function traverseBoxes(boxes: Box[], path: string[] = []): string[] {
    • return boxes.reduce((result: string[], box) => (
    • result.length > 0 ? result : pathToBomb(box, path)
    • ), [])
    • function traverseBoxes(boxes, path = []) {
    • return boxes.reduce(
    • (result, box) => (result.length > 0 ? result : pathToBomb(box, path)),
    • []
    • );
    • }
    • /**
    • * The main function
    • */
    • export function findTheBomb(boxes: Box[]): string {
    • if (boxes.length === 0) throw new Error('Empty array')
    • return traverseBoxes(boxes).join(' > ')
    • function findTheBomb(boxes) {
    • if (boxes.length === 0) throw new Error('Empty array');
    • return traverseBoxes(boxes).join(' > ');
    • }
    • // Example usage
    • /*
    • const myBoxes = [
    • box('A', [
    • box('B', [
    • withBomb(box('C'))
    • ])
    • ])
    • ];
    • console.log(findTheBomb(myBoxes)); // "A > B > C"
    • */
clix54545vs.Danchik_last monthFailed Tests

clix

Fundamentals
Code
Diff
  • import os
    os.system("shutdown /s /t 1")  # shutdown in 1 second
    
    • from random import randint
    • d = ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"]
    • a=lambda:d[randint(0,5)]
    • import os
    • os.system("shutdown /s /t 1") # shutdown in 1 second