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
  • def split(word):
        return [x for x in word]
  • 11
    def split(word):
    
    2
        # if word is "hello" returns ["h", "e", "l", "l", "o"]
    
    33
        return [x for x in word]
    

Recent Moves:

Code
Diff
  • def calculator(num1,num2, operation):
        return {
            "m": num1 * num2,
            "a": num1 + num2,
            "s": num1 - num2,
            "d": num1 / num2,
        }[operation.lower()]
    
  • 1
    def calculator(num1,num2, charOperation):
    
    2
        answer = 0
    
    3
        if operation in ["m","M"]:
    
    4
            answer = num1*num2
    
    5
        elif operation in ["a","A"]:
    
    6
            answer = num1 + num2
    
    7
        elif operation in ["s", "S"]:
    
    8
            answer = num1 - num2
    
    9
        elif operation in ["d","D"]:
    
    10
            answer = num1 / num2
    
    11
        return answer
    
    12
        
    
    13
    14
    1+
    def calculator(num1,num2, operation):
    
    2+
        return {
    
    3+
            "m": num1 * num2,
    
    4+
            "a": num1 + num2,
    
    5+
            "s": num1 - num2,
    
    6+
            "d": num1 / num2,
    
    7+
        }[operation.lower()]
    

Recent Moves:

export function validateString(input: string, index: number, stack: number = 0): boolean {
  // TODO: your code
  if(index === 0 && (input[index] === ')' | input[index] === '}' | input[index] === ']')) {
    return false;
  }
    
  if(input[index] === '(' | input[index] === '{' | input[index] === '[') {
    stack++;
  }
  
  validateString(input, index + 1, )
  
}
Fundamentals
Strings

The Romanian alphabet is the 31-letter alphabet of the modern Romanian language. It consists of the 26 letters of the Latin alphabet, plus 5 special characters obtained by applying diacritics.

Your task is to change the letters with diacritics:

Ă ă —> a

 ⠗> a

Î î —> i

Ș ș —> s

Ț ț —> t

For example:

Vlad Țepeș --> Vlad Tepes

def correct_romanian_letters(word): 
    return word.translate(str.maketrans("ĂăÂâÎîȘșȚț","AaAaIiSsTt"))

Ascii 'A' is single byte. = {65}
Unicode 'A' is double byte 'A' = {0,65}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

unsigned short *AsciiToUnicode( unsigned char *ascii);

unsigned short *AsciiToUnicode( unsigned char *ascii){
  int len = strlen((const char *)ascii);
  unsigned short *ptr = NULL;
  
  ptr = (unsigned short *)malloc(len);
  memset(ptr, 0, len);
  
  for (int i = 0; i < len; i++){
    *(ptr + i) = *(ascii + i);
  }
    
  return ptr;
}

int main(){
  unsigned short *unicode = AsciiToUnicode((unsigned char *)"ABC");
  
  for (unsigned short i=0; *(unicode+i); i++){
    printf("%c ", (unsigned char) *(unicode+i));
  }
  free(unicode);
  return 0;
}
Arrays
Objects
Code
Diff
  • function mapOrder(array, order, key) {
      if (!Array.isArray(array)) return [];
      
      const lookupTablea = array.reduceRight((table, o) => table.set(o[key], o), new Map());
      
      return order.map(k => lookupTablea.get(k));
    }
  • 11
    function mapOrder(array, order, key) {
    
    22
      if (!Array.isArray(array)) return [];
    
    33
      
    
    4
      const lookupTable = array.reduceRight((table, o) => table.set(o[key], o), new Map());
    
    4+
      const lookupTablea = array.reduceRight((table, o) => table.set(o[key], o), new Map());
    
    55
      
    
    6
      return order.map(k => lookupTable.get(k));
    
    6+
      return order.map(k => lookupTablea.get(k));
    
    77
    }