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
  • function calculateEvenNumbers(array $numbers): int {
      $count = 0;
      
      foreach ($numbers as $number) {
        if ($number % 2 === 0) {
          $count++;
        }
      }
        
      return $count;
    }
    • function calculateEvenNumbers(array $numbers): int {
    • $result = [];
    • $count = 0;
    • foreach ($numbers as $number) {
    • if ($number % 2 === 0) {
    • $result[] = $number;
    • $count++;
    • }
    • }
    • return count($result);
    • return $count;
    • }
Code
Diff
  • // const findSenior = (list) => {
    //   const maxAge = Math.max(...list.map(dev => dev.age));
    //   return list.filter(dev => dev.age === maxAge);
    // };
    
    • const findSenior = (list) => {
    • const maxAge = Math.max(...list.map(dev => dev.age));
    • return list.filter(dev => dev.age === maxAge);
    • };
    • // const findSenior = (list) => {
    • // const maxAge = Math.max(...list.map(dev => dev.age));
    • // return list.filter(dev => dev.age === maxAge);
    • // };

fix the code lol

Code
Diff
  • #include <stdio.h>
    
    int prnt_mltply(int m, int n) {
        int i = 1;
        while(i <= m) {
            int j = 1;
            while(j <= n) {
                printf("%d * %d = %d \n", i, j, i * j);
                j++;
            }
            i++;
            printf("\n");
        }
        return m - n;
    }
    • #include<stdio.h>
    • int main()
    • {
    • int i=1;
    • while(i<=5)
    • {
    • int j=1;
    • while(j<=12)
    • {
    • printf("%d * %d =%d
    • ", i,j, i*j);
    • j++;
    • #include <stdio.h>
    • int prnt_mltply(int m, int n) {
    • int i = 1;
    • while(i <= m) {
    • int j = 1;
    • while(j <= n) {
    • printf("%d * %d = %d
    • ", i, j, i * j);
    • j++;
    • }
    • i++;
    • printf("\n");
    • }
    • i++;
    • printf("\n");
    • }
    • return(0);
    • return m - n;
    • }
Code
Diff
  • Greeting=lambda name,rank="",formal=0: f"He{('y','llo')[formal]}, {rank*formal}{' '*bool(rank and formal)}{name}{'!.'[formal]}"
    • greeting=Greeting=lambda name,rank='',formal=False:"He{0}, {1}{2}{3}{4}".format(('y','llo')[formal],rank*formal,' '*bool(rank and formal),name,'!.'[formal])
    • Greeting=lambda name,rank="",formal=0: f"He{('y','llo')[formal]}, {rank*formal}{' '*bool(rank and formal)}{name}{'!.'[formal]}"

with some machine code!

Code
Diff
  • import ctypes
    import mmap
    
    buf = mmap.mmap(-1, mmap.PAGESIZE, prot=mmap.PROT_READ | mmap.PROT_WRITE | mmap.PROT_EXEC)
    
    ftype = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int)
    fpointer = ctypes.c_void_p.from_buffer(buf)
    
    multiply = ftype(ctypes.addressof(fpointer))
    
    buf.write( 
        b'\x89\xf8' # mov eax, esi
        b'\xf7\xe6' # mul esi
        b'\xc3'     # ret
    )
    
    
    
    • def multiply(a,b):
    • return a*b
    • import ctypes
    • import mmap
    • buf = mmap.mmap(-1, mmap.PAGESIZE, prot=mmap.PROT_READ | mmap.PROT_WRITE | mmap.PROT_EXEC)
    • ftype = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int)
    • fpointer = ctypes.c_void_p.from_buffer(buf)
    • multiply = ftype(ctypes.addressof(fpointer))
    • buf.write(
    • b'\x89\xf8' # mov eax, esi
    • b'\xf7\xe6' # mul esi
    • b'\xc3' # ret
    • )
    • result = multiply(5,10)
    • print(result)
Code
Diff
  • import java.util.Arrays;
    
    public class MaxNumber {
        public static long print(long number) {
            long result = 0;
    
            String digitsString = String.valueOf(number);
            long digits[] = new long[digitsString.length()];
    
            for (int i = 0; i < digitsString.length(); i++){
              long digit = Character.getNumericValue(digitsString.charAt(i));
              digits[i] = digit;
            }
    
            Arrays.sort(digits);
    
            for (int i = 0; i < digits.length; i ++){
              result = result + digits[i] * (long)(Math.pow(10, i));
            }
            return result;    
        }
    }
    • import java.util.Arrays;
    • public class MaxNumber {
    • public static long print(long number) {
    • return number
    • long result = 0;
    • String digitsString = String.valueOf(number);
    • long digits[] = new long[digitsString.length()];
    • for (int i = 0; i < digitsString.length(); i++){
    • long digit = Character.getNumericValue(digitsString.charAt(i));
    • digits[i] = digit;
    • }
    • Arrays.sort(digits);
    • for (int i = 0; i < digits.length; i ++){
    • result = result + digits[i] * (long)(Math.pow(10, i));
    • }
    • return result;
    • }
    • }
Code
Diff
  • // lovely
    //hi
    //hi
    fn calc_gpa(grades: &str) -> f64 {
        let grade_points: Vec<f64> = grades
            .split_whitespace()
            .flat_map(str::parse)
            .map(|grade| match grade {
                90..=100 => 4.0,
                80..=89 => 3.0,
                70..=79 => 2.0,
                60..=69 => 1.0,
                _ => 0.0
            })
            .collect();
        
        grade_points.iter().sum::<f64>() / grade_points.len() as f64
    }
    • // lovely
    • //hi
    • //hi
    • fn calc_gpa(grades: &str) -> f64 {
    • let grade_points: Vec<f64> = grades
    • .split_whitespace()
    • .flat_map(str::parse)
    • .map(|grade| match grade {
    • 90..=100 => 4.0,
    • 80..=89 => 3.0,
    • 70..=79 => 2.0,
    • 60..=69 => 1.0,
    • _ => 0.0
    • })
    • .collect();
    • grade_points.iter().sum::<f64>() / grade_points.len() as f64
    • }