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
  • using System;
    class Kata {
        public static void Main(string greeting, string language) {
    			Console.WriteLine("{0}, {1}!", greeting, language);
        }
    }
    • using System;
    • class Kata {
    • public static void Main(string greeting, string language) {
    • Console.WriteLine($"{greeting}, {language}!");
    • Console.WriteLine("{0}, {1}!", greeting, language);
    • }
    • }
Code
Diff
  • module NCR where
    
    --Combinations nCr
    comb:: Integer -> Integer -> Integer
    comb n r = factorial n `div` (factorial r * factorial (n-r))
      where
      factorial n = foldr (*) 1 [2..n]
    • module NCR where
    • --Combinations nCr
    • comb:: Integer -> Integer -> Integer
    • comb n r | n/=r = (factorial n) `div` (factorial r * factorial (n-r) )
    • | n==r = (factorial n) `div` (factorial r)
    • factorial n= foldl (*) 1 [1..n]
    • comb n r = factorial n `div` (factorial r * factorial (n-r))
    • where
    • factorial n = foldr (*) 1 [2..n]

Allow for passing parents into the constructor. Also, add some spaces to make code consistent. Also, avoid mutating parents array, just for the sake of it.

Code
Diff
  • class Human {
      constructor (firstName = '', lastName = '', parents = []) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.parents = parents;  // modern family. who takes parental care?
      }
      
      filterMyFamily(humans) {
        return humans.filter(human => human.lastName === this.lastName)
      }
      
      hasParent(p) {
        return this.parents.some(parent => parent === p);
      }
      
      hasChild(c) {
        return c.hasParent(this);
      }
      
      addParent(p) {
        if (!this.hasParent(p)) this.parents = [ ...this.parents, p ];
        return this;
      }
    }
    • class Human {
    • constructor (firstName = '', lastName = '') {
    • constructor (firstName = '', lastName = '', parents = []) {
    • this.firstName = firstName;
    • this.lastName = lastName;
    • this.parents = []; // modern family. who takes parental care?
    • this.parents = parents; // modern family. who takes parental care?
    • }
    • filterMyFamily(humans) {
    • return humans.filter(human => human.lastName === this.lastName)
    • }
    • addParent(p){
    • if (!this.hasParent(p)) this.parents.push(p);
    • return this;
    • hasParent(p) {
    • return this.parents.some(parent => parent === p);
    • }
    • hasChild(c){
    • hasChild(c) {
    • return c.hasParent(this);
    • }
    • hasParent(p){
    • return this.parents.some(parent => parent === p);
    • addParent(p) {
    • if (!this.hasParent(p)) this.parents = [ ...this.parents, p ];
    • return this;
    • }
    • }
Strings
Data Types
Code
Diff
  • def last_char(s):
      return list(s).pop()
    • def last_char(s):
    • return s[-1]
    • return list(s).pop()