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
  • let results = [
      {materia: {conteudo: {titulo: 'São Paulo'}}, tags: [1, 2, 3]},
      {materia: {conteudo: {}}, tags: [3, 2]},
      {materia: {conteudo: {titulo: 'Rio de Janeiro'}}, tags: [3, 2]},
    ];
    
    for (const {materia: {conteudo: {titulo = 'Brasil'}}} of results){ 
    
    console.log(titulo);
    }
    • let results = [
    • {materia: {conteudo: {titulo: 'São Paulo'}}, tags: [1, 2, 3]},
    • {materia: {conteudo: {}}, tags: [3, 2]},
    • {materia: {conteudo: {titulo: 'Rio de Janeiro'}}, tags: [3, 2]},
    • ];
    • for (const result of results) {
    • let titulo = result.materia.conteudo.titulo || 'Brasil';
    • console.log(titulo);
    • for (const {materia: {conteudo: {titulo = 'Brasil'}}} of results){
    • console.log(titulo);
    • }
Code
Diff
  • var bg = 'gray';
    
    var css = `
      <style>
      body {
        background:${bg};
        color: black;
       }
      </style>`;
      
    
    • var bg = 'gray';
    • var css = '' +
    • '<style>' +
    • 'body {' +
    • ' background: '+ bg + ';' +
    • ' color: black;'
    • '}' +
    • '</style>';
    • var css = `
    • <style>
    • body {
    • background:${bg};
    • color: black;
    • }
    • </style>`;
Code
Diff
  • // reescreva em ES6
    function main(a, b = 2, c = 3) {
        
        return a * b * c;
    }
    • // reescreva em ES6
    • function main(a, b, c) {
    • if (typeof b == 'undefined')
    • b = 2;
    • if (typeof c == 'undefined')
    • c = 3
    • function main(a, b = 2, c = 3) {
    • return a * b * c;
    • }
Numbers
Data Types
Interview Questions

Converts a number to English. This is a horrendous mess...

(ns number-to-words
  (:require [clojure.string :refer [join]]))

(def digit-to-word
  {1 "One"
   2 "Two"
   3 "Three"
   4 "Four"
   5 "Five"
   6 "Six"
   7 "Seven"
   8 "Eight"
   9 "Nine"})

(def tens-to-word
  {
   20 "Twenty"
   30 "Thirty"
   40 "Fourty"
   50 "Fifty"
   60 "Sixty"
   70 "Seventy"
   80 "Eighty"
   90 "Ninety"})

(def teen-to-word
  {10 "Ten"
   11 "Eleven"
   12 "Twelve"
   13 "Thirteen"
   14 "Fourteen"
   15 "Fifteen"
   16 "Sixteen"
   17 "Seventeen"
   18 "Eighteen"
   19 "Nineteen"})

(defn- small-number-to-words
  [x]
  (cond
   (<= x 9) (digit-to-word x)
   (< x 20) (teen-to-word x)
   (< x 100)
   (let [ones-part (mod x 10)
         tens-part (- x ones-part)]
     (str (tens-to-word tens-part) "-"
          (digit-to-word ones-part)))
   (<= x 999)
   (let [small-part (mod x 100)
         hundreds-digit (-> x (- small-part) (/ 100))]
     (str (digit-to-word hundreds-digit) " Hundred " (small-number-to-words small-part)))))

(defn- digit-shift
  [x shift]
  (-> x (- (mod x shift)) (/ shift) int))

(defn convert
  [x]
  (loop [words [] x x]
    (cond
     
     (-> x (>= 1e6))
     (recur (conj words "One Million")
            (- x 1e6))
     
     (-> x (>= 1e3))
     (recur (conj words
                  (str
                   (-> x (digit-shift 1000) small-number-to-words)
                   " Thousand"))
            (mod x 1000))
     
     (-> x (> 0))
     (recur (conj words (small-number-to-words x)) 0)
     
     :else (join ", " words))))
Code
Diff
  • const firstNonRepeatingCharacter = str => {
      const obj = [...str].reduce((a,c) => {a[c]?a[c]++:a[c]=1;return a},{});
      return Object.keys(obj).find(e => obj[e]===1)||null;
    };
    • const firstNonRepeatingCharacter = (str) => {
    • for (let i = 0; i < str.length; i++) {
    • let seenDuplicate = false;
    • for (let j = 0; j < str.length; j++) {
    • if (str[i] === str[j] && i !== j) {
    • seenDuplicate = true;
    • break;
    • }
    • }
    • if (!seenDuplicate) {
    • return str[i];
    • }
    • }
    • return null; // return null if no unique character is found
    • const firstNonRepeatingCharacter = str => {
    • const obj = [...str].reduce((a,c) => {a[c]?a[c]++:a[c]=1;return a},{});
    • return Object.keys(obj).find(e => obj[e]===1)||null;
    • };
Code
Diff
  • fn sum(arr: &[i32]) -> i32 {
        match arr.is_empty() {
            true => 0,
            false => arr[..].iter().sum::<i32>(),
        }
    }
    • def sum(arr):
    • result = 0
    • for i in arr:
    • result += i
    • return result
    • fn sum(arr: &[i32]) -> i32 {
    • match arr.is_empty() {
    • true => 0,
    • false => arr[..].iter().sum::<i32>(),
    • }
    • }
Code
Diff
  • sum = (a,b) => a+b;
    • function sum(a,b) {
    • return a+b; // wrong returning
    • }
    • sum = (a,b) => a+b;
Code
Diff
  • digitToText = d => ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'][d]
    • const nums = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
    • function digitToText(digit) {
    • return nums[digit]
    • }
    • digitToText = d => ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'][d]
Code
Diff
  • const MEANING_OF_LIFE: i32 = 42;
    • def meaning_of_life_is():
    • return """
    • go crazy with your imagination and return anything you like.
    • strings, numbers, ... just don't return None.
    • may the most creative answer win
    • """
    • const MEANING_OF_LIFE: i32 = 42;
Code
Diff
  • // # def multiply (a,b):
    // #     return a * b
    
    
    
    const multiply = (a, b) =>  {
      return a * b 
    };
    • // # def multiply (a,b):
    • // # return a * b
    • multiply = (a, b) => a * b;
    • const multiply = (a, b) => {
    • return a * b
    • };