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

:D

Code
Diff
  • divisors=lambda n:[x for x in range(1,n+1)if n%x<1]
    • divisors=lambda n:[x for x in range(1,n+1)if n%x==0]
    • divisors=lambda n:[x for x in range(1,n+1)if n%x<1]
Variables
Basic Language Features
Fundamentals
Conditional Statements
Control Flow
Loops
Arrays
Data Types
Code
Diff
  • from math import sqrt
    
    def is_prime(num):
        for newnum in range(2, int(sqrt(num)) + 1):
            if num % newnum == 0:
                return False
        return False if num == 1 else True
    
    def get_primes(num):
        return [n for n in range(1, num + 1) if is_prime(n)]
      
    • from math import sqrt
    • def is_prime(num):
    • newnum = num - 1
    • while newnum > 1:
    • if num % newnum == 0:
    • return False
    • newnum -= 1
    • if newnum > 1:
    • continue
    • return True
    • for newnum in range(2, int(sqrt(num)) + 1):
    • if num % newnum == 0:
    • return False
    • return False if num == 1 else True
    • def get_primes(num):
    • og, c = num, []
    • while num > 0:
    • if is_prime(num):
    • c.append(num)
    • num -= 1
    • if og > 1:
    • c.append(2)
    • return sorted(c, reverse=False)
    • return [n for n in range(1, num + 1) if is_prime(n)]
Code
Diff
  • const findMax = (a) => {
      if (a !== undefined && a !== null) {
        return a.sort((a, b) => a - b)[a.length - 1];
      } else return;
    };
    • const findMax = a => Math.max(...a);
    • const findMax = (a) => {
    • if (a !== undefined && a !== null) {
    • return a.sort((a, b) => a - b)[a.length - 1];
    • } else return;
    • };

FizzBuzz using pattern matching

Code
Diff
  • using System;
    
    namespace Solution {
      class FizzBuzz {
        public static string Convert(int input) => input switch
        {
          {} when input.IsDivisibleBy(3) && input.IsDivisibleBy(5) => "FizzBuzz",
          {} when input.IsDivisibleBy(3) => "Fizz",
          {} when input.IsDivisibleBy(5) => "Buzz",
          _ => input.ToString()
        };
      }
      
      static class IntExtensions {
        public static bool IsDivisibleBy(this int dividend, int divisor) => dividend % divisor == 0;
      }
    }
    • using System;
    • namespace Solution {
    • class FizzBuzz {
    • public static string Convert(int input)
    • {
    • var divisableBy3 = input % 3 == 0;
    • var divisableBy5 = input % 5 == 0;
    • return (!divisableBy3 & !divisableBy5) ? input.ToString()
    • : (divisableBy3 ? "Fizz" : string.Empty) + (divisableBy5 ? "Buzz" : string.Empty);
    • }
    • public static string Convert(int input) => input switch
    • {
    • {} when input.IsDivisibleBy(3) && input.IsDivisibleBy(5) => "FizzBuzz",
    • {} when input.IsDivisibleBy(3) => "Fizz",
    • {} when input.IsDivisibleBy(5) => "Buzz",
    • _ => input.ToString()
    • };
    • }
    • static class IntExtensions {
    • public static bool IsDivisibleBy(this int dividend, int divisor) => dividend % divisor == 0;
    • }
    • }