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

Create a function that does four basic mathematical operations.

The function should take three arguments - operation(string/char), value1(number), value2(number).
The function should return result of numbers after applying the chosen operation.

example:
basicOp('+', 4, 8) // Output: 12
basicOp('-', 14, 18) // Output: -4
basicOp('*', 5, 4) // Output: 20
basicOp('/', 49, 7) // Output: 7

Suppose we're adding 1 and -1. That would return 0, which would be a valid result for this operation. But trying to use an invalid operation would also return 0, so now there's no concrete way of knowing if the function executed correctly.

function basicOp(operation, value1, value2) {
    switch (operation) {
        case '+':
            return value1 + value2;
        case '-':
            return value1 - value2;
        case '*':
            return value1 * value2;
        case '/':
            return value1 / value2;
        default:
            return 0;
            //Suppose we're adding 1 and -1.
    }
}

Your task:
Instead of writing out the same code over and over, let’s make the computer loop through our array for us. We can do this with for loops.

Some help for beginners:

Since this syntax is a little complicated, let’s break it into 4 parts:

Within the for loop’s parentheses, the start condition is var i = 0, which means the loop will start counting at 0.

The stop condition is i < animals.length, which means the loop will run as long as i is less than the length of the animals array. When i is greater than the length of the animals array, the loop will stop looping.

The iterator is i++. This means that each loop, i will have 1 added to it.

And finally, the code block is inside the { ... }. The block will run each loop, until the loop stops.

Tip of the day:
The secret to loops is that i, the variable we created inside the for loop’s parentheses, is always equal to a number. To be more clear, the first loop, i will equal 0, the second loop, i will equal 1, and the third loop, i will equal 2.

This makes it possible to write animals[0], animals[1], animals[2] programmatically instead of by hand. We can write a for loop, and replace the hard coded number with the variable i, like this: animals[i].

var animals = ["Grizzly Bear", "Sloth", "Sea Lion"];

//your code here
}

Write a function that takes an integer as input, and returns boolean divisibility by 3 for input argument. You can't use / as operator

Example: The number 3 is divisible by three without leaving a remainder, so the function should return true in this case

function dividedByThree(int $number): bool
{
    $i = 3;
    do {
        if (abs($number) === $i) {
            return true;
        }
        $i += 3;
        
    } while (abs($number) >= $i);
    
    return false;
}

You will have an input and a factor.
Multiply the String by the factor.
For example: "hi",2 -> "hihi"

public class Kata{		
		public static String multiply(String input,int times){
		String save = input;
		for (int i = 1; i < times; i++) {
			System.out.println(input);
			input += save;
		}
      if(times == 0){
      input = "";
      }
		return input;
	}
}

FilteredText array needs to check all its objects and their properties. If the property is different then it becames "Mixed data".

The Output should look like this:

filteredText = [
{
innerHTML: 'Hello World',
fontSize: 'Mixed data',
fontWeight: '700',
},
{
innerHTML: 'Hello World',
fontSize: 'Mixed data',
fontWeight: '400',
},
{
innerHTML: 'Hello World',
fontSize: 'Mixed data',
fontWeight: '400',
},
]

let baseData = [
  {
    input_text1: "{'innerHTML': 'Hello World', 'fontSize': '5', 'fontWeight': '700'}",
    input_text2: "{'innerHTML': 'Hello World', 'fontSize': '5', 'fontWeight': '400'}",
    input_text3: "{'innerHTML': 'Hello World', 'fontSize': '5', 'fontWeight': '400'}",
    input_shape1: "{x: 7, y, 150, width: 50, height: 50}",
    input_shape2: "{x: 150, y, 80, width: 50, height: 50}",
    input_shape3: "{x: 67, y, 150, width: 50, height: 50}",
  },
  
  {
    input_text1: "{'innerHTML': 'Hello World', 'fontSize': '10', 'fontWeight': '700'}",
    input_text2: "{'innerHTML': 'Hello World', 'fontSize': '5', 'fontWeight': '400'}",
    input_text3: "{'innerHTML': 'Hello World', 'fontSize': '5', 'fontWeight': '400'}",
    input_shape1: "{x: 50, y, 150, width: 50, height: 50}",
    input_shape2: "{x: 150, y, 80, width: 50, height: 50}",
    input_shape3: "{x: 30, y, 150, width: 50, height: 50}",
  },
  
  {
    input_text1: "{'innerHTML': 'Hello World', 'fontSize': '5', 'fontWeight': '700'}",
    input_text2: "{'innerHTML': 'Hello World', 'fontSize': '5', 'fontWeight': '400'}",
    input_text3: "{'innerHTML': 'Hello World', 'fontSize': '5', 'fontWeight': '400'}",
    input_shape1: "{x: 7, y, 150, width: 50, height: 50}",
    input_shape2: "{x: 150, y, 50, width: 50, height: 50}",
    input_shape3: "{x: 67, y, 150, width: 50, height: 50}",
  },
]




let filteredText = baseData.map(el => {
     return Object.entries(el).filter(key => key[0].includes('text'))
});
Arithmetic
Mathematics
Algorithms
Logic
Numbers
def greatest_common_divisor(*args):

    def gcd(a, b):
        if a == b: return a
        elif a > b:
            return (gcd(b, a % b) if a % b != 0 else b)
        else:
            return gcd(b, a)

    res = gcd(args[0], args[1])
    if len(args) > 2:
        for i in range(2, len(args)):
            res = gcd(res, args[i])
    return res

A Class that helps with computing Fibonacci numbers, by treating them as linkedlist entries.

Calling FibonacciSequence next() outputs a biginteger for the current fibonacci value of the sequence's instance.

The sequence starts at 1.

import java.math.BigInteger;

public class FibonacciSequence {
	private BigInteger first;
	private BigInteger second;

	public FibonacciSequence() {
		second = BigInteger.ONE;
		first = BigInteger.ZERO;
	}

	public BigInteger next() {
		BigInteger returnVal = second;
		updateValues();
		return returnVal;
	}

	private void updateValues() {
		BigInteger t = second;
		second = first.add(t);
		first = t;
	}
}

wenn der übergebenen string mit a anfängt, gebe true zurück

public class test{
  public static Boolean anfanga(String s){
    if(s.startsWith("a")){
      return true;
    } else {
      return false;
    }
  }
}

You type a string of a list of numbers, and this method returns the highest int and the lowest int in the string.

public class ns {
	
	public static String highAndLow(String numbers) {
		String[] integerStrings = numbers.split(" "); 

		int[] integers = new int[integerStrings.length]; 

		for (int i = 0; i < integers.length; i++){
		    integers[i] = Integer.parseInt(integerStrings[i]); 
	
		}
		    int maxValue = integers[0];
		    for(int y=1;y < integers.length;y++){
		      if(integers[y] > maxValue){
		  	  maxValue = integers[y];
		      }
		    }
		    int minValue = integers[0];
		    for(int q=1;q<integers.length;q++){
		      if(integers[q] < minValue){
		  	  minValue = integers[q];
		}
	}

		String s = Integer.toString(maxValue);
		String m = Integer.toString(minValue);
		String r = s + " " + m;
	
		return r;
}
public static void main(String args[]) {
		
		System.out.println(highAndLow("13 48 19 20 24 12"));
		
	}
	
}
miketsouFailed Tests

skata

gfxcngfxcgnfxcgfn

test = () => 3