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
Code
Diff
  • package cat;
    public class kata{
    public static int doubleValue(int x) {
        return x + x;
    }
    }
    • package cat;
    • public class kata{
    • public static int doubleValue(int x) {
    • return x * 2;
    • return x + x;
    • }
    • }
Code
Diff
  • def is_even(x):
        return True if divmod(x,2)[1] == 0 else False
    
    • def is_even(x):
    • return x & 1 == 0
    • return True if divmod(x,2)[1] == 0 else False
Fundamentals
Code
Diff
  • package kata
    
    import (
    	"fmt"
    )
    
    func main() {
    	fmt.Println("Hello Golang")
    }
    • package main
    • package kata
    • import (
    • "fmt"
    • )
    • func main() {
    • fmt.Println("Hello Golang")
    • }
Code
Diff
  • class EvenOrOdd {    
      static String evenOrOdd(int n) {
        return new String[]{"Even", "Odd"}[n & 1];
      }
    }
    • class EvenOrOdd {
    • static String evenOrOdd(int n) {
    • return n % 2 > 0 ? "Odd" : "Even";
    • return new String[]{"Even", "Odd"}[n & 1];
    • }
    • }
Arrays

RRAYS
The police have placed radars that will detect those vehicles that exceed the speed limit on that road. If the driver's speed is 10km/h to 19km/h above the speed limit, the fine will be 100 $, if it is exceeded by 20km/h to 29km/h the fine will be 250 $ and if it is exceeded by more than 30km/h the fine will be 500 $.

You will be provided with the speed limits of those roads with radar as an collection of integers [90,100,110,120,....] and the speed of the driver will be the same on all roads and can never be negative and the amount of the fine will be accumulated example 95km/h.

Example (Speed=100, Signals=[110,100,80]-> 250$)

Code
Diff
  • public class Kata {
        
        public static int speedLimit(int speed, int[] signals) {
          int penalty = 0;
          
          for (int signal : signals) {
            int diffSpeed = speed - signal;
            penalty += (diffSpeed > 29) ? 500 : (diffSpeed > 19) ? 250 : (diffSpeed > 9) ? 100 : 0;
          }      
          return penalty;
        }
    }
    • public class Kata {
    • public static int speedLimit(int speed, int[] signals) {
    • int penalty = 0;
    • for (int signal : signals) {
    • final int diff = speed - signal;
    • if (diff >= 30) penalty += 500;
    • else if (diff >= 20) penalty += 250;
    • else if (diff >= 10) penalty += 100;
    • int diffSpeed = speed - signal;
    • penalty += (diffSpeed > 29) ? 500 : (diffSpeed > 19) ? 250 : (diffSpeed > 9) ? 100 : 0;
    • }
    • return penalty;
    • }
    • }
Code
Diff
  • unsigned long long div2(unsigned long long a) {
      long long i = 0;
      while (a>=2){
        a -= 2;
        i++;
      }
      return i;
    }
    • unsigned long long div2(unsigned long long a) {
    • long long i = 0;
    • while (a>=2){
    • a = a-2;
    • a -= 2;
    • i++;
    • }
    • return i;
    • }