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
  • find_multiples = lambda b, l:[x for x in range(b,l+1,b)]
    • def find_multiples(b, l):
    • a=[]
    • for i in range(b,l+1,b):
    • a.append(i)
    • return a
    • find_multiples = lambda b, l:[x for x in range(b,l+1,b)]
Code
Diff
  • factorial=$=_=>_?_*$(~-_):!_
    • $=_=>_<!_?!!_+!_:_*$(_-!!_+!_)
    • factorial=$
    • factorial=$=_=>_?_*$(~-_):!_
Objects
Data Types
Strings

Write a function that processes the properties of a given object, by the following rules:

  • Each property that has an underscore (_) in its name will be converted to a nested object
  • Properties that have only underscores or no properties, will remain the same
  • The last nested property will hold the original value

Example:

const beforeTransformation = {
  a_b_c: "value"
}

const afterTransformation = {
  a: {
    b: {
      c: "value"
    }
  }
}
Code
Diff
  • export const transform = (source: Record<string, any>): Record<string, any> => {
        const target = Object.create(null);
        // TODO: handle invalid property
        Object.entries(source).forEach(([key, value]) => {
            key.split("_").slice(0, -1).reduce((node: Record<string, any>, element: string) => {
                return node[element] ??= {};
            }, target)[key.slice(key.lastIndexOf("_") + 1)] = value;
        });
        return target;
    }
    • export function transform(source: any) {
    • const target = {};
    • Object.entries(source).forEach(function ([k, v]) {
    • k.split("_").slice(0, -1).reduce(function (node: {[key: string]: any}, element: string) {
    • export const transform = (source: Record<string, any>): Record<string, any> => {
    • const target = Object.create(null);
    • // TODO: handle invalid property
    • Object.entries(source).forEach(([key, value]) => {
    • key.split("_").slice(0, -1).reduce((node: Record<string, any>, element: string) => {
    • return node[element] ??= {};
    • }, target)[k.slice(k.lastIndexOf("_") + 1)] = v;
    • }, target)[key.slice(key.lastIndexOf("_") + 1)] = value;
    • });
    • return target;
    • }
Strings
Data Types
Iterators
Control Flow
Object-oriented Programming
Basic Language Features
Fundamentals
Programming Paradigms

Given a string, complete the function so it returns the string with every 2nd character removed.

example:

removeEverySecond('hello world') should return 'hlowrd' ```
Code
Diff
  • def removeEverySecond(string):
        # Your code goes here
        return string[::2]
    • removeEverySecond=\
    • lambda s:s[::2]
    • def removeEverySecond(string):
    • # Your code goes here
    • return string[::2]
Lists
Data Structures
Code
Diff
  • def generate_binary_list(a, b, c, d):
        (a, b) = (a, b, a)[d&1:][:2]
        return [*((a, b)*(c-d>>1)), *(a,)[:c>d][:c-d&1]]
    • def generate_binary_list(a, b, c, d):
    • (a, b) = ((a, b), (b, a))[d&1]
    • return [*((a, b)*(c-d>>1)), *((), (a,))[c>d][:c-d&1]]
    • (a, b) = (a, b, a)[d&1:][:2]
    • return [*((a, b)*(c-d>>1)), *(a,)[:c>d][:c-d&1]]
Code
Diff
  • revstr=s=>[...s].reverse().join``
    • revstr=s=>s.split``.reverse().join``
    • revstr=s=>[...s].reverse().join``
Regular Expressions
Declarative Programming
Advanced Language Features
Programming Paradigms
Fundamentals
Strings
Code
Diff
  • class StringParity {
        public static boolean isEvenLength(String str) {
          return (str.length() & 1) == 0;
        }
    }
    • class StringParity {
    • public static boolean isEvenLength(String str) {
    • return str.length() % 2 == 0;
    • }
    • public static boolean isEvenLength(String str) {
    • return (str.length() & 1) == 0;
    • }
    • }