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
  • import re
    def AmIYelling(input_sentence):
        return True if(len(re.sub('[^a-z]','',input_sentence))==0) else False
    • import re
    • def AmIYelling(input_sentence):
    • return len([l for l in input_sentence if ((l.isalpha() and l.isupper())or not l.isalpha())]) == len(input_sentence)
    • return True if(len(re.sub('[^a-z]','',input_sentence))==0) else False
Code
Diff
  • import java.lang.Math;
    public class BiggerNum{
    
      /**
       * @param a integer of param1
       * @param b integer of param2
       * @return the bigger integer of a and b
       * If a equals b, return either one
       */
      public static int compare(int a, int b) {
        return Math.max(a,b);
      }
    }
    • import java.lang.Math;
    • public class BiggerNum{
    • /**
    • * @param a integer of param1
    • * @param b integer of param2
    • * @return the bigger integer of a and b
    • * If a equals b, return either one
    • */
    • public static int compare(int a, int b) {
    • return Math.max(a,b);
    • }
    • }
Code
Diff
  • def add(s, o):
        s = map(int, s)
        s = {
            1: (c for c in s if c % 2),
            2: (c for c in s if not c % 2),
        }.get(o, s);
        return sum(s)
    • def add(s, o):
    • s = map(int, s)
    • s = {
    • 1: (c for c in s if c % 2),
    • 2: (c for c in s if c % 2 == 0),
    • 2: (c for c in s if not c % 2),
    • }.get(o, s);
    • return sum(s)

How about fix Open/Close principle violation?

Code
Diff
  • using System;
    using System.Collections.Generic;
    using System.Linq;
    
    public enum Quality { SD, HD, UHD }
    
    public class TV
    {
        private class Contract
        {
            public string Type;
            public Func<int, Quality, bool> Condition;
    
            public static readonly IList<Contract> Types =
                new List<Contract>
                {
                    new Contract { Type = "PREMIUM", Condition = (numDevices, quality) => numDevices == 4 && quality == Quality.UHD },
                    new Contract { Type = "STANDARD", Condition = (numDevices, quality) => numDevices == 2 && quality == Quality.HD },
                    new Contract { Type = "ESSENTIAL", Condition = (numDevices, quality) => numDevices == 1 && quality == Quality.SD },
                    new Contract { Type = "INVALID", Condition = (numDevices, quality) => true }         
                };
        }
    
        public static string GetContract(int numDevices, Quality quality)
        {
            return Contract.Types.First(contract => contract.Condition(numDevices, quality)).Type;
        }
    }
    • using System;
    • using System.Collections.Generic;
    • using System.Linq;
    • public enum Quality { SD, HD, UHD }
    • public class TV
    • {
    • public static string GetContract( int numDevices, Quality quality)
    • {
    • string result = "INVALID";
    • if (numDevices == 4 && quality == Quality.UHD)
    • result = "PREMIUM";
    • else if (numDevices == 2 && quality == Quality.HD)
    • result = "STANDARD";
    • else if (numDevices == 1 && quality == Quality.SD)
    • result = "ESSENTIAL";
    • return result;
    • }
    • }
    • private class Contract
    • {
    • public string Type;
    • public Func<int, Quality, bool> Condition;
    • public static readonly IList<Contract> Types =
    • new List<Contract>
    • {
    • new Contract { Type = "PREMIUM", Condition = (numDevices, quality) => numDevices == 4 && quality == Quality.UHD },
    • new Contract { Type = "STANDARD", Condition = (numDevices, quality) => numDevices == 2 && quality == Quality.HD },
    • new Contract { Type = "ESSENTIAL", Condition = (numDevices, quality) => numDevices == 1 && quality == Quality.SD },
    • new Contract { Type = "INVALID", Condition = (numDevices, quality) => true }
    • };
    • }
    • public static string GetContract(int numDevices, Quality quality)
    • {
    • return Contract.Types.First(contract => contract.Condition(numDevices, quality)).Type;
    • }
    • }
Numbers
Data Types
Code
Diff
  • def kilogramsToGrams(kilograms):
        return kilograms * 1000
    • def kilotograms(kilograms):
    • pass
    • def kilogramsToGrams(kilograms):
    • return kilograms * 1000
Mathematics
Algorithms
Logic
Numbers
Fundamentals
Code
Diff
  • def population_tracking(i, c, n):
        return -(-i*((1+(c/100))**(n))//1)
    • import math
    • def population_tracking(i, c, n):
    • return math.ceil(i*((1+(c/100))**(n)))
    • return -(-i*((1+(c/100))**(n))//1)