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

IMHO it is strange to return true or false depending on a 'bool' condition

Code
Diff
  • using System;
    
    public class LeapYears
    {
      public static bool IsLeapYear(int year)
      {
        return year % 4 == 0 && !(year%100==0 && year % 400 != 0);
      }
    }
    • using System;
    • public class LeapYears
    • {
    • public static bool IsLeapYear(int year)
    • {
    • // End of a century must be divisible by 400
    • if(year%100==0)
    • return year % 400 == 0;// Returns true if year divisible by 400, false otherwise
    • else if(year % 4 == 0)
    • return true;// Returns true if year divisible by 4 and not end of the century
    • else
    • return false;
    • return year % 4 == 0 && !(year%100==0 && year % 400 != 0);
    • }
    • }
Code
Diff
  • function prime_checker(n) {
    	if (n <= 1) return false
    	for (let i = 2; i <= Math.sqrt(n); i++) {
    		if (n % i == 0) return false
    	}
    	return true
    }
    • function prime_checker(n)
    • {
    • if(n <= 1)
    • {
    • return false;
    • }
    • for(var i = 2; i <= Math.sqrt(n); i++)
    • {
    • if(n%i == 0)
    • {
    • return false;
    • }
    • }
    • return true;
    • function prime_checker(n) {
    • if (n <= 1) return false
    • for (let i = 2; i <= Math.sqrt(n); i++) {
    • if (n % i == 0) return false
    • }
    • return true
    • }
Strings
Parsing
Code
Diff
  • const stripEnds = (s, prefix, suffix) => s.replace(new RegExp(`[${prefix}${suffix}]`, 'gi'), '')
    
    • function stripEnds(s, prefix, suffix) {
    • return s.replace(new RegExp(`[${prefix}${suffix}]`, 'gi'), '');
    • }
    • const stripEnds = (s, prefix, suffix) => s.replace(new RegExp(`[${prefix}${suffix}]`, 'gi'), '')
Code
Diff
  • def find_multiples(n):
        return sum({*range(4, n, 4), *range(6, n, 6)})
    • def find_multiples(n):
    • return sum({num for num in range(4, n, 4)} | {num for num in range(6, n, 6)})
    • return sum({*range(4, n, 4), *range(6, n, 6)})
Code
Diff
  • Unit Kata;
    interface
    
    function IsLeap(year: integer): boolean;
    
    implementation
      
    function IsLeap(year: integer): boolean;
    begin
      result := (year mod 400 = 0) or ((year mod 4 = 0) and (year mod 100 <> 0));
    end;
    
    end.
    • bool isLeap(int year) {
    • return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
    • }
    • Unit Kata;
    • interface
    • function IsLeap(year: integer): boolean;
    • implementation
    • function IsLeap(year: integer): boolean;
    • begin
    • result := (year mod 400 = 0) or ((year mod 4 = 0) and (year mod 100 <> 0));
    • end;
    • end.