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

The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.

There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.

How many circular primes are there below one million?

function countCirculars(n) {
  let count = 0;

  for (let i=3;i<=n; i+=2) {
    if (isPrime(i) && isCirclePrime(i))
      count++;
  }

  return count+1;
}

function isPrime(n) {
  for (let i=2; i<=Math.sqrt(n); i++) {
    if (n%i === 0)
      return false;
  }
  return true;
}

function isCirclePrime(n) {
  let strN = n.toString();
  for (let i = 1; i<strN.length; i++) {
    strN = shiftString(strN);
    if (!isPrime(parseInt(strN)))
      return false
  }
  return true;
}

function shiftString(str) {
  return str.substring(1) + str.substring(0,1);
}

Return the names of everyone to greet with "Hello".

SELECT name FROM greetings
WHERE greeting='Hello';

That's my first kumite... don't really know what all this is about...

using System;
using System.Linq;

public class Kata
{
      public static int DuplicateCount(string str)
      {
            var orderedLowercase = str.ToLower().OrderBy(c => c);
            var countDuplicates = 0;
            var countOccurrenciesCurrentCharacter = 1;
            char? previousElement = null;
            var firstElement = true;

            foreach(var currentElement in orderedLowercase)
            {
                if (firstElement)
                {
                    firstElement = false;
                }
                else
                {
                    if (currentElement == previousElement.Value)
                    {
                        countOccurrenciesCurrentCharacter ++;

                        if (countOccurrenciesCurrentCharacter == 2)
                        {
                            countDuplicates ++;
                        }
                    }
                    else
                    {
                        countOccurrenciesCurrentCharacter = 1;
                    }
                }
                previousElement = currentElement;
            }
            return countDuplicates;
      }

}
const convert = (num) => {
  return parseFloat(num.toFixed(2));
};

There can only be one bulbul!

def sayHello(say):
    l = ["bulbul", "8===D"]
    return l

Could be done better?

package main

import "fmt"

func swap(dataset []int, a, b int) {
  var x int = dataset[a]
  dataset[a] = dataset[b]
  dataset[b] = x
}

func bubble_sort(dataset []int, amout_of_integers int){
  for i := 0; i <= amout_of_integers; i++ {
    for j := amout_of_integers; j >= i + 1; j-- {
      if dataset[j] < dataset[j-1] {
        swap(dataset, j, j - 1)
      }
    }
  }
}


func main(){

  dataset := []int{5, 2, 4, 6, 1, 3};

  fmt.Println(dataset)

  bubble_sort(dataset, 5);

  fmt.Println(dataset)
}

Provide a positive integer (0 < n).

Returns an array of all factors of n.

If there are no factors, returns an empty array.

Based on user boo1ean's solution here: https://www.codewars.com/kata/reviews/55aa0d71c1eba8a65a000132/groups/5787db6eba5c4b1c8c0016ae

function getFactors (n) {
  if (n < 1 || ! Number.isInteger(n)) return [];
  
  let divisors = [];
  
  // Only iterates up to n/2, since no divisor will be greater than that
  for (let i = 1; i <= n / 2; ++i) {
    if (n % i) continue;
    else divisors.push(i);
  }
  
  // Push the original number n to array
  return divisors.concat([n]);
}

A little help for claculate the distances between two points in a plane(2D case) and in the space (3D case)

from math import sqrt

def distance2D(pA, pB):
    if pA == pB: return 0
    xA, yA = tuple(pA); xB, yB = tuple(pB)
    return sqrt((xA - xB)**2 + (yA - yB)**2)
    
def distance3D(pA, pB):
    if pA == pB: return 0
    xA, yA, zA = tuple(pA); xB, yB, zB = tuple(pB)
    return sqrt((xA - xB)**2 + (yA - yB)**2 + (zA - zB) **2)

A little help for claculate the distances between two points in a plane(2D cases) and in the space (3D cases)

def distance2D(pA, pB)
    return 0 if pA == pB
    xA = pA[0]; yA = pA[1]; xB= pB[0]; yB = pB[1]
    return Math.sqrt((xA - xB)**2 + (yA - yB)**2)
end
    
def distance3D(pA, pB)
    return 0 if pA == pB
    xA = pA[0]; yA = pA[1]; zA = pA[2]; xB= pB[0]; yB = pB[1]; zB = pB[2]
    return Math.sqrt((xA - xB)**2 + (yA - yB)**2 + (zA - zB) **2)
end  

def range (min, max)
    rand * (max-min) + min
end

A little help to calculate the distances between two points in a plane(2D cases) and in the space (3D cases)

function distance2D(pA, pB) {
    if (pA == pB) return 0;
    var xA = pA[0], yA = pA[1], xB= pB[0], yB = pB[1];
    return Math.sqrt((xA - xB)**2 + (yA - yB)**2)
}
    
function distance3D(pA, pB) {
    if (pA == pB) return 0;
    var xA = pA[0], yA = pA[1], zA = pA[2], xB= pB[0], yB = pB[1], zB = pB[2];
    return Math.sqrt((xA - xB)**2 + (yA - yB)**2 + (zA - zB) **2);
}