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
Code
Diff
  • fn digit_sum(number: i128) -> u32 {
        number
            .to_string()
            .chars()
            .map(|c| c.to_digit(10))
            .flatten()
            .sum()
    }
    
    • def digit_sum(number: int) -> int:
    • return(sum([int(num) for num in str(abs(number))]))
    • fn digit_sum(number: i128) -> u32 {
    • number
    • .to_string()
    • .chars()
    • .map(|c| c.to_digit(10))
    • .flatten()
    • .sum()
    • }
Code
Diff
  • def sum(*args) -> int:
        black_list = [str(type("")), str(type({}))]
        sum_of_args = 0
        for i in args:
            if str(type(i)) in black_list:
                exit(1)
            else:
                if str(type(i)) == str(type([])):
                    for k in range(len(i)):
                        sum_of_args += i[k]
                else:
                    sum_of_args += i
        return sum_of_args
    • def sum(arr):
    • var = 0
    • for i in arr:
    • var += i
    • return var
    • def sum(*args) -> int:
    • black_list = [str(type("")), str(type({}))]
    • sum_of_args = 0
    • for i in args:
    • if str(type(i)) in black_list:
    • exit(1)
    • else:
    • if str(type(i)) == str(type([])):
    • for k in range(len(i)):
    • sum_of_args += i[k]
    • else:
    • sum_of_args += i
    • return sum_of_args
Code
Diff
  • fun returnInt(int:Int): Int = int
    
    • fun returnInt(int:Int): Int{
    • return int
    • }
    • fun returnInt(int:Int): Int = int
Code
Diff
  • from functools import reduce
    print(f'hello\n{reduce(lambda x, y: x + y, [2, 5])}')
    
    • print("hello")
    • print(2+5)
    • from functools import reduce
    • print(f'hello\n{reduce(lambda x, y: x + y, [2, 5])}')

Minus 7

How many times can you subtract 7 from a given number?

Examples

numMinusSeven(1000) === 143;
numMinusSeven(100) === 15;
numMinusSeven(10) === 2;
Code
Diff
  • function numMinusSeven(num) {
        return Math.ceil(num / 7)
    }
    
    • function numMinusSeven(num) {
    • let arr = []
    • while (num > 0) {
    • num -= 7
    • arr.push(num)
    • }
    • return arr.length
    • return Math.ceil(num / 7)
    • }
Code
Diff
  • export type BmiProps = {
      height: number;
      weight: number;
    };
    
    export type CalculateBmiProps = BmiProps & {
      system: "metric" | "imperial";
    };
    
    export const imperialToMetric = ({ height, weight }: BmiProps): BmiProps => {
      return { height: height * 0.3048, weight: weight * 0.453592 };
    };
    
    export const calculateBmi = (
      { height, weight, system }: CalculateBmiProps,
    ): number => {
      const { height: h, weight: w } = system === "imperial"
        ? imperialToMetric({ height, weight })
        : { height, weight };
      
      return Math.round((w / (h ** 2)) * 100) / 100;
    };
    • export default class BMI {
    • private _height: number;
    • private _weight: number;
    • constructor(weight: number, height: number) {
    • this._height = height;
    • this._weight = weight;
    • }
    • set height(height: number) {
    • if (height <= 0) {
    • const invalidValueError = new Error('Invalid value');
    • console.error(invalidValueError);
    • }
    • this._height = height;
    • }
    • set width(weight: number) {
    • if (weight <= 0) {
    • const invalidValueError = new Error('Invalid value');
    • console.error(invalidValueError);
    • }
    • export type BmiProps = {
    • height: number;
    • weight: number;
    • };
    • this._weight = weight;
    • }
    • get bmi(): number {
    • return Number((this._weight / Math.pow(this._height, 2)).toFixed(2));
    • }
    • export type CalculateBmiProps = BmiProps & {
    • system: "metric" | "imperial";
    • };
    • export const imperialToMetric = ({ height, weight }: BmiProps): BmiProps => {
    • return { height: height * 0.3048, weight: weight * 0.453592 };
    • };
    • export const calculateBmi = (
    • { height, weight, system }: CalculateBmiProps,
    • ): number => {
    • const { height: h, weight: w } = system === "imperial"
    • ? imperialToMetric({ height, weight })
    • : { height, weight };
    • calculateBMI(): string {
    • return `there is ${this.bmi < 25 ? 'no ' : ''}excess weight`;
    • }
    • }
    • return Math.round((w / (h ** 2)) * 100) / 100;
    • };
Code
Diff
  • pub fn bool_check(bools: [bool; 3]) -> bool {
        bools.into_iter().filter(|&b| b).count() >= 2
    }
    • public class Kumite {
    • public static boolean boolCheck(boolean[] bools) {
    • return bools[0] ? bools[1] || bools[2] : bools[1] && bools[2];
    • }
    • pub fn bool_check(bools: [bool; 3]) -> bool {
    • bools.into_iter().filter(|&b| b).count() >= 2
    • }

Description:
Function that checks if two char arrays contain a common item between
them.

Code
Diff
  • using System.Collections.Generic;
    using System.Linq;
    public class Kata
    {
        /// <summary>
        /// Checks if two char arrays contain at least one common item.
        /// </summary>
        /// <param name="a">First char array</param>
        /// <param name="b">Second char array</param>
        /// <returns>True if the arrays have at least one common item, false otherwise</returns>
        public static bool ContainsCommonItem(char[] a, char[] b)
        {
          return a == null || b == null ? false : a.Intersect(b).Any();
        }
    }
    
    • using System.Collections.Generic;
    • using System.Linq;
    • public class Kata
    • {
    • /// <summary>
    • /// Checks if two char arrays contain at least one common item.
    • /// </summary>
    • /// <param name="a">First char array</param>
    • /// <param name="b">Second char array</param>
    • /// <returns>True if the arrays have at least one common item, false otherwise</returns>
    • public static bool ContainsCommonItem(char[] a, char[] b)
    • {
    • // If either input array is null, return false
    • if (a == null || b == null) return false;
    • return a.Intersect(b).Any();
    • return a == null || b == null ? false : a.Intersect(b).Any();
    • }
    • }
Code
Diff
  • select * from employees where employees.salary>5000000 and employees.months>=12
    order by employees.salary desc
    • -- Code Here
    • select * from employees where employees.salary>5000000 and employees.months>=12
    • order by employees.salary desc