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
u
homo
gg
aapo huijjaa
module Example where

isPoly :: Integer -> Bool
isPoly 0 = True
isPoly n = n `mod` len n == 0 && isPoly (n `div` 10)

len :: Integer -> Integer
len 0 = 0
len n = 1 + len (n `div` 10)

This is a way to calculate GPA, is this a good way? I need some tests...

y = 0
    while (y <=5):
        grade = input("Enter Your Grade For Each Class Listed in Order (Letter Form): ")
        grade = grade.upper()
        grades.append(grade)
        y = y + 1
    calculate()

def calculate():
    total= 0
    for element in grades:
        if element == "A+":
            total = total + 4.0
        elif element == "A":
            total = total + 4.0
        elif element == "A-":
            total = total + 3.7
        elif element == "B+":
            total = total + 3.3
        elif element == "B":
            total = total + 3.0
        elif element == "B-":
            total = total + 2.7
        elif element == "C+":
            total = total + 2.3
        elif element == "C":
            total = total + 2.0
        elif element == "C-":
            total = total + 1.7
        elif element == "D":
            total = total + 1.0
    gpa = total / 6
    print(gpa)


collect()

Given a user can select any 3 non-repeating numbers n from a range of 1-10, identify any prime numbers where 1 <= prime_numbers <= n. n is an integer of all the 4 selected numbers put together in the order they were chosen. So selecting numbers 1, 12, 8 is 1128.

Return the middle most prime number. If there are an even number of prime numbers, get the lower number.

def middle_prime(*args):
	maximum = 10
	try:
		if len(args) > 3:
			raise Exception('Only 3 numbers are allowed.')
		else:
			for i in args:
				if not 0 < i <= maximum:
					raise Exception('Only type numbers from 1 to {}.'.format(maximum))

		num = int(''.join([str(i) for i in args]))
		primes = [i for i in range(2, num + 1) if is_prime(i)]
		if primes:
			mididx = len(primes) // 2 if len(primes) % 2 else len(primes) // 2 - 1
			return primes[mididx]
		return -1
	except Exception as e:
		return e

def is_prime(int:int):
	for i in range(2, int):
		if not int % i:
			return False
	return True

C++17:

The implementation may assume that any thread will eventually do one of the following:

  • terminate,
  • make a call to a library I/O function,
  • perform an access through a volatile glvalue, or
  • perform a synchronization operation or an atomic operation.
#include <iostream>

bool disproveFermat() {
  const int MAX = 1000;
  int a = 1, b = 1, c = 1;
  while (true) {
    if (a*a*a == b*b*b + c*c*c) return true;
    a++;
    if (a > MAX) { a = 1; b++; }
    if (b > MAX) { b = 1; c++; }      
    if (c > MAX) { c = 1; }
  }
  return false;
}

int main() {
  std::cout << (disproveFermat() ? "Disproved!" : "Not disproved");
}

Without using Array.prototype.flat() implement a flatten function.

Eg.

flatten([1, [2, [3]], 4]) // returns [1, 2, 3, 4]
function flatten(input) {
  return input.reduce((arr, value) => {
    return [
      ...arr,
      ...(Array.isArray(value) ? flatten(value) : [value])
    ];
  }, []);
}

It is easy, for example: you have to change "Hello World" to "HeLlOwOrLd".

public class HeLlOwOrLddddd {
  public static String convert(String input) {
      String salida = "";
      boolean mayus = true;
      for (int i=0;i<input.length();i++){
        if (Character.isLetter(input.charAt(i))){
            if (mayus){
                salida+=Character.toUpperCase(input.charAt(i));
                mayus=false;
            }else{
                salida+=Character.toLowerCase(input.charAt(i));
                mayus=true;
            }
        }        
    }
      return salida;

  }
}