Begin a new Kumite
Search
About
  • Filter by Language:
    Ad
  • 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 remove_numbers(string):
        return ''.join(c for c in string if not c.isdigit())
    • import re
    • def remove_numbers(string):
    • return ''.join(c for c in string if not c.isdigit())
Code
Diff
  • class StringReversal:
        """String reversal class."""
    
        def __init__(self, param=None):
            """Initialize attributes."""
            self.pram = param
            self.output = ''
    
        def reversal(self):
            """Reverses self.param, and returns the value"""
            for i in range(len(str(self.pram)) - 1, -1, -1):
                self.output += str(self.pram)[i]
            if isinstance(self.pram, (dict, list, set, tuple)):
                return f'{self.output[-1:]}{self.output[1:-1]}{self.output[:1]}'
            return self.output
    
    • //import java.util.Scanner;
    • import java.lang.StringBuilder;
    • class StringReversal:
    • """String reversal class."""
    • public class Practice01{
    • public static String reverse(String input) {
    • /*Scanner sc = new Scanner(System.in);
    • System.out.println("Give the desired string to be reversed :");
    • String e = sc.nextLine();*/
    • return new StringBuilder(input).reverse().toString();
    • }
    • }
    • def __init__(self, param=None):
    • """Initialize attributes."""
    • self.pram = param
    • self.output = ''
    • def reversal(self):
    • """Reverses self.param, and returns the value"""
    • for i in range(len(str(self.pram)) - 1, -1, -1):
    • self.output += str(self.pram)[i]
    • if isinstance(self.pram, (dict, list, set, tuple)):
    • return f'{self.output[-1:]}{self.output[1:-1]}{self.output[:1]}'
    • return self.output
Code
Diff
  • convert_binary_decimal = lambda n: int(str(n), 2)
    • convert_binary_decimal = lambda number: int(f"{number}", 2)
    • convert_binary_decimal = lambda n: int(str(n), 2)
Code
Diff
  • fn solution(mut x: i32) -> bool {
        match x.to_string().chars().into_iter().position(|s| s == '3') {
            Some(_t) => true,
            _e => false,
        }
    }
    • fn solution(mut x: i32) -> bool {
    • for d in x.to_string().chars() {
    • if d == '3' {
    • return true;
    • }
    • match x.to_string().chars().into_iter().position(|s| s == '3') {
    • Some(_t) => true,
    • _e => false,
    • }
    • false
    • }
Code
Diff
  • increment_string = lambda s, i=lambda s: next((len(s)-e for e,x in enumerate(s[::-1]) if not x.isdigit()), 0): s[:i(s)] + f'{int(s[i(s):] or 0) + 1}'.rjust(len(s[i(s):]), "0")
    • import re
    • def increment_string(s):
    • end_nums = re.match(".+?(\d+)$", s)
    • if end_nums:
    • padded_number = '{:0>{}}'.format(int(end_nums[1])+1, len(end_nums[1]))
    • return s[:end_nums.span(1)[0]] + padded_number
    • return s + '1'
    • increment_string = lambda s, i=lambda s: next((len(s)-e for e,x in enumerate(s[::-1]) if not x.isdigit()), 0): s[:i(s)] + f'{int(s[i(s):] or 0) + 1}'.rjust(len(s[i(s):]), "0")

Going for style points

Code
Diff
  • int *fanis(char *r,int k) {
        char *w = malloc(0);
        for (int i = 0; r[i]; w[i++] = k + r[i]);
        return w;
    }
    • int*fanis(char*r,int k){char*w=malloc(0);for(int i=0;r[i];w[i++]=k+r[i]);return w;}
    • int *fanis(char *r,int k) {
    • char *w = malloc(0);
    • for (int i = 0; r[i]; w[i++] = k + r[i]);
    • return w;
    • }