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
Sets

Best not to use eval and best to keep "const" out of func.

Code
Diff
  • wins = {
        "Rock": "Paper",
        "Paper": "Scissors",
        "Scissors": "Rock"
    }
    def dumbRockPaperScissors(player1, player2):
        if player1 == wins[player2]:
            return "Player 1 wins"
        elif player2 == wins[player1]:
            return "Player 2 wins"
        else:
            return "Draw"
     
    
    • wins = {
    • "Rock": "Paper",
    • "Paper": "Scissors",
    • "Scissors": "Rock"
    • }
    • def dumbRockPaperScissors(player1, player2):
    • Rock = {"Paper"}
    • Paper = {"Scissors"}
    • Scissors = {"Rock"}
    • if player1 in eval(player2):
    • if player1 == wins[player2]:
    • return "Player 1 wins"
    • elif player2 in eval(player1):
    • elif player2 == wins[player1]:
    • return "Player 2 wins"
    • else:
    • return "Draw"
Code
Diff
  • const firstNonRepeatingCharacter = (str) => {
        const lookup = {};
        let potentialWinners = [];
        for(let i = 0; i < str.length; i++) {
            const c = str[i];
          if(lookup[c] && lookup[c] == 1){
            potentialWinners = potentialWinners.filter(pw => pw !== c);
            lookup[c] = 2;
            continue;
          }
          lookup[c] = 1;
          potentialWinners.push(c);
        }
        return potentialWinners.length == 0 ? null : potentialWinners[0]; // return null if no unique character is found
    };
    • 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];
    • }
    • const lookup = {};
    • let potentialWinners = [];
    • for(let i = 0; i < str.length; i++) {
    • const c = str[i];
    • if(lookup[c] && lookup[c] == 1){
    • potentialWinners = potentialWinners.filter(pw => pw !== c);
    • lookup[c] = 2;
    • continue;
    • }
    • lookup[c] = 1;
    • potentialWinners.push(c);
    • }
    • return null; // return null if no unique character is found
    • return potentialWinners.length == 0 ? null : potentialWinners[0]; // return null if no unique character is found
    • };
Code
Diff
  • fn tab(f: fn(i32) -> i32, a: i32, b: i32, h: usize) -> i32 {
        (a..=b).step_by(h).map(f).sum()
    }
    • const tab = (f, a, b, h) => {
    • fn tab(f: fn(i32) -> i32, a: i32, b: i32, h: usize) -> i32 {
    • (a..=b).step_by(h).map(f).sum()
    • }
Code
Diff
  • #include <stdint.h>
    
    uint32_t sum(uint32_t a, uint32_t b)
    {
    	if(a == 0u)
    	{
    		return b;
    	}
    	return sum(a-1, b+1);
    }
    • function sum(a,b) {
    • return a+b; // wrong returning
    • #include <stdint.h>
    • uint32_t sum(uint32_t a, uint32_t b)
    • {
    • if(a == 0u)
    • {
    • return b;
    • }
    • return sum(a-1, b+1);
    • }
Code
Diff
  • const digitToText = digit => ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'][digit];
    • const nums = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
    • function digitToText(digit) {
    • return nums[digit]
    • }
    • const digitToText = digit => ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'][digit];
Code
Diff
  • class Kata {
    
      public static String verifySum(String nameOne, String nameTwo) {
            if(nameOne == null || nameTwo == null) {
                return "NULL";
            }
            int sum = 0, lengthOne = nameOne.length(), lengthTwo = nameTwo.length();
            for(int i = 0; i < lengthOne; i++) {
                char c = nameOne.charAt(i);
                sum += c > 96 ? c - 32 : c;
            }
            for(int i = 0; i < lengthTwo; i++) {
                char c = nameTwo.charAt(i);
                sum -= c > 96 ? c - 32 : c;
            }
            return sum == 0 ? "TRUE" : "FALSE";
        }
    }
    • class Kata{
    • class Kata {
    • public static String verifySum(String nameOne, String nameTwo) {
    • int[] sumOfNames = new int[]{0, 0};
    • if (nameOne == null || nameTwo == null) {
    • if(nameOne == null || nameTwo == null) {
    • return "NULL";
    • }
    • for (int i = 0; i < nameOne.length(); i++){
    • sumOfNames[0] += nameOne.charAt(i);
    • int sum = 0, lengthOne = nameOne.length(), lengthTwo = nameTwo.length();
    • for(int i = 0; i < lengthOne; i++) {
    • char c = nameOne.charAt(i);
    • sum += c > 96 ? c - 32 : c;
    • }
    • for (int i = 0; i < nameTwo.length(); i++){
    • sumOfNames[1] += nameTwo.charAt(i);
    • for(int i = 0; i < lengthTwo; i++) {
    • char c = nameTwo.charAt(i);
    • sum -= c > 96 ? c - 32 : c;
    • }
    • return sumOfNames[0] == sumOfNames[1] ? "TRUE" : "FALSE";
    • return sum == 0 ? "TRUE" : "FALSE";
    • }
    • }
Code
Diff
  • function multiply(a, b)
    {
      return a*b;
    }
    • def multiply (a,b):
    • a * b
    • function multiply(a, b)
    • {
    • return a*b;
    • }