Begin a new Kumite
Search
About
  • Filter by Language:
  • 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.

Code
Diff
  • function a(){
      // We shall remove the following solution when publish as KATA
      static $poi = null;
      if ($poi) return $poi->create();
      $poi = new class {
         public function create() {
            return new static();
         }
      };
      return $poi->create();
    }
  • 11 function a(){
    2+ // We shall remove the following solution when publish as KATA
    22 static $poi = null;
    33 if ($poi) return $poi->create();
    44 $poi = new class {
    55 public function create() {
    66 return new static();
    77 }
    88 };
    99 return $poi->create();
    1010 }

Simpler ternary way: if a and b really are equal it doesn't matter which one gets returned

Code
Diff
  • public class BiggerNum{
    
      /**
       * @param a integer of param1
       * @param b integer of param2
       * @return the bigger integer of a and b
       * If a equals b, return either one
       */
      public static int compare(int a, int b) {
        return a > b ? a : b;
      }
    }
  • 11 public class BiggerNum{
    22
    33 /**
    44 * @param a integer of param1
    55 * @param b integer of param2
    66 * @return the bigger integer of a and b
    77 * If a equals b, return either one
    88 */
    99 public static int compare(int a, int b) {
    10- return a > b ? a : a < b ? b : a;
    10+ return a > b ? a : b;
    1111 }
    1212 }
Bugs

One line version with error output as lambda (analog of arrow function in Python) looks like this.

Code
Diff
  • div = lambda num1, num2 : print("Division failed: division by zero") if num2 == 0 else print("Division failed: integers and floats accepted only") if not(isinstance(num1, (int, float)) and isinstance(num2, (int, float))) else num1 / num2
    
  • 1-let divide = (num1, num2) => num2 === 0 ? console.log("Division failed: division by zero") : !(num1 === +num1 && num2 === +num2) ? console.log("Division failed: integers and floats accepted only") : num1/num2
    1+div = lambda num1, num2 : print("Division failed: division by zero") if num2 == 0 else print("Division failed: integers and floats accepted only") if not(isinstance(num1, (int, float)) and isinstance(num2, (int, float))) else num1 / num2
Fundamentals
Arrays

Different way wihout using reduce and forEach.

Code
Diff
  • function getSum(array) {
       return eval(array.join("+"))
    }
  • 11 function getSum(array) {
    2- //your code
    2+ return eval(array.join("+"))
    33 }