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
  • import sys
    sys.stdout.write("Hello Python!")
    • from __future__ import print_function
    • print("Hello Python", end="!\n")
    • import sys
    • sys.stdout.write("Hello Python!")
Code
Diff
  • #include "iostream"
    
    int main(){
      namespace std {
        cout << "Hello C++" << endl;
      }
    }
    • #include "iostream"
    • using namespace std;
    • int main(){
    • cout << "Hello C++" << endl;
    • namespace std {
    • cout << "Hello C++" << endl;
    • }
    • }

Bash is pretty silly...

Code
Diff
  • #!/bin/bash
    printf "Hello %s!\n" "Bash"
    • #!/bin/bash
    • echo Hello Bash!
    • #!/bin/bash
    • printf "Hello %s!\n" "Bash"

Even more golfing

Code
Diff
  • (ns bubble
      (:refer-clojure :exclude [sort]))
    
    (defn bubble [[truck & [jeep & bigdogs :as convoy] :as tanks]]
      (cond
       (some nil? [truck convoy]) [tanks true]
       (<= truck jeep) (update-in (bubble convoy) [0] conj truck)
       :else [(cons jeep (first (bubble (cons truck bigdogs)))) false]))
    
    (defn sort [l]
      (let [[value done?] (bubble l)]
        (if done?
          value
          (recur value))))
    • (ns bubble
    • (:refer-clojure :exclude [sort]))
    • (defn bubble [tanks]
    • (if (or (nil? tanks) (nil? (next tanks)))
    • [tanks false]
    • (let [[truck & [jeep & _ :as convoy]] tanks]
    • (if (<= truck jeep)
    • (let [debrief (bubble convoy)] (cons (cons truck (first debrief)) (next debrief)))
    • (cons (cons jeep (first (bubble (cons truck (next convoy))))) '(true))))))
    • (defn bubble [[truck & [jeep & bigdogs :as convoy] :as tanks]]
    • (cond
    • (some nil? [truck convoy]) [tanks true]
    • (<= truck jeep) (update-in (bubble convoy) [0] conj truck)
    • :else [(cons jeep (first (bubble (cons truck bigdogs)))) false]))
    • (defn sort [l]
    • (let [bubbly (bubble l)]
    • (if (second bubbly)
    • (recur (first bubbly))
    • (first bubbly))))
    • (let [[value done?] (bubble l)]
    • (if done?
    • value
    • (recur value))))
Arrays
Data Types
Blocks
Object-oriented Programming
Functions
Programming Paradigms
Control Flow
Basic Language Features
Fundamentals

A refactor of jhoffner's code. I edited the Array#sum code, so take a look at the changes.

Code
Diff
  • class Array
      def sum(&block)
        block = Proc.new {|n| n} unless block_given?
        inject(0) {|result, item| result + block.call(item) rescue result}
      end
      
      def mean(&block)
        sum(&block).to_f / size
      end
    end
    • class Array
    • def sum(&block)
    • inject(0) do |result, item|
    • item = block_given? ? yield(item) : item
    • result + (item || 0)
    • end
    • block = Proc.new {|n| n} unless block_given?
    • inject(0) {|result, item| result + block.call(item) rescue result}
    • end
    • def mean(&block)
    • sum(&block).to_f / size
    • end
    • end