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

Returns true if the sentence is every letter in it is Capital.

It wil also return true if there is no letter inside.

HELLO
IM YELLING
1234
!!

Are examples.

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)
Fundamentals
Arrays
Data Types

Get the sum of all integers in the given array... and return it.

function getSum(array) {
   //your code
}

Given this array of string arrays, generate a comment with the first element of the inner arrays (randomizing will not be testable)

Input: [['hi,', 'hello,', 'hey,'], ['how are'], ['you', 'ya'], ['doing', 'going'], ['?','?!', '']]

Output: 'hi, how are you doing?'

var generateComment = function (array){
  
}
Interview Questions
Algorithms
Logic

Flip an image vertically (i.e. top becomes the bottom and vice versa) where you are only able to get the pixel data based on it's index within the image. For example, the 4th index on a 3 x 3 image would be the center square.
012
345
678

You can only access the pixel data using the getPixel(index) function.
You can also modify the pixel Data within the Array using the putPixel(index, value) function.
You do not neccesarily need to flip the image in place to perform the flip, but it is required for the array object to be overwritten with the new array once it has completed.
An example Array has been provided:
array=[[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15],[16,17,18,19]]
This should return:
[[16, 17, 18, 19], [12, 13, 14, 15], [8, 9, 10, 11], [4, 5, 6, 7], [0, 1, 2, 3]]

A maximum of two for loops are allowed to be used, and bonus points are awarded for simplicity and efficiency.

def swapPixel(array, index1, index2):
    temp = getPixel(array, index1)
    putPixel(array, index1, getPixel(array, index2))
    putPixel(array, index2, temp)

def horizontalFlipPair(array, index):
    return (int((len(array)/2)+((len(array)/2)-int(index/len(array[0]))))-1)*len(array[0])+index%len(array[0])

def flipImage(array):
    for i in range(int(len(array)*len(array[0])/2)):
        swapPixel(array, i, horizontalFlipPair(array, i))

def simpleFlipPair(array, index):
    w = len(array[0])
    m = (len(array)-1)/2
    l = int(index/w)
    a = (m-l)*w
    return int(2*(a)+index)

def flipImage(array):
    for i in range(int(len(array)/2*len(array[0]))):
        swapPixel(array, i, simpleFlipPair(array, i))
def add(a, b):
    pass # Fill this up

Suppose you have a string that looks something like this "1 + 2 * (2 - (3.1415 / 2.7^(2.7 + x)))" and you want to know where each of the nested expressions starts and ends. You can use ParseNestedness().

ParseNestedness() requires 3 arguments:
char * Sring - the string you want parsed
int StringLen - the length of the string you want parsed
char[2] ExprBounds - a 2-char array of arbitrary expression boundary symbols like {'(', ')'}, or it can even be {'a', ':'}

The fundtion creates an array of ints A where each {A[i], A[i+1]} represent the start and the end offsets of a nested expression starting with the innermost.

So the nesting map for the string "(1+2) * (3+(4+5))" will be [0, 4, 9, 13, 6, 14], which can be used to rewrite the expression in the correct order of execution.

#include <string.h>
#include <stdlib.h>
#include <stdio.h>

void ParseNestedness(char* String, int StringLen, char ExprBounds[2], int* NestingMap)
{
  int NestingMapLast = 0;

  int BoundsStack[StringLen];
  int BoundsStackLast = 0;

  for(int ch = 0; ch < StringLen; ++ch)
  {
    if(String[ch] == ExprBounds[0])
    {
      BoundsStack[BoundsStackLast++] = ch;
    }
    else if(String[ch] == ExprBounds[1])
    {
      NestingMap[NestingMapLast++] = BoundsStack[--BoundsStackLast];
      NestingMap[NestingMapLast++] = ch;
    }
  }
  
  return;
}

int main()
{
  char* TestString = "(-1+0)*(1+(2+(3+4)))*(5+6)";
  char  ExprBounds[2] = {'(', ')'};

  int* NestingMap = (int*)malloc(sizeof(int) * 10);

  ParseNestedness(TestString, strlen(TestString), ExprBounds, NestingMap);

  for(int i = 0; i < 10; ++i)
  {
    printf("%i ", NestingMap[i]);
  }
  printf("\n");
  
  return 0;
}

eğer parametreden verilen metin değer içinde tüm karakterler benzersiz ise true, tekrar eden bir karakter var ise false değer dönmeli.
Küçük-büyük karaketer fark etmez.

isIsogram "Dermatoglyphics" == true
isIsogram "moose" == false
isIsogram "aba" == false
using System;
using System.Linq;
public class Kata
{
  public static bool IsIsogram(string str) 
  {
    //return str.ToLower().Distinct().Count()==str.Length;
  }
}

given a number (n) return the text for hoe it is spoken. e.g.:

10 => "ten"

99 => "ninety nine"

-1 => "negative one"

231 => "two hundred and thirty one"

I will make the smallest number -999 and the largest 999 for simplicity. you can asume all numbers are valid intagers, but check the range. If a number is out of range return "unsupported number";

function Generrate (n)
{

	var out = "";
  
	var str_arrOfDigits = n.toString().split("");
  
	if (str_arrOfDigits[0] == "-")
	{
		out += "negative ";
		str_arrOfDigits.splice(0,1);
	}
	
    switch (str_arrOfDigits.length) {
		case 1:
			out += Digits(str_arrOfDigits[0]);
			break;
		case 2:
			out += getDoubleDigit(str_arrOfDigits);
			break;
		case 3:
			out += getTrippleDigit(str_arrOfDigits)
			break;
		default:
			return "unsupported number";
			break;
	}
    return out;
};
function Digits(n) {
  return ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"][n];
};

function tens(n) {
  return ["zero", "ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"][n];
};
	
function getDoubleDigit (arr)
{
	var out = "";
	
	if (arr[0] == "1") {
		out = Digits(arr.join().replace("," ,""));
	}
	else {
		if (arr[0] != "0")
			out = tens(arr[0]) + (arr[1] != "0"? " " +  Digits(arr[1]): "");
		else
			out = Digits(arr[1]);
	}
	return out;
}

function getTrippleDigit (arr)
{
	var firstDigit = Digits(arr[0]);
	var doubleDigits = getDoubleDigit(arr.splice(1));
	return (firstDigit != "zero"? firstDigit + " hundred" : "") + (firstDigit != "zero" && doubleDigits != "zero"? " and " +  doubleDigits : (doubleDigits != "zero"? doubleDigits : ""));
}

You and your friend only have a limit span of free time per day to meet, given your free hour range and his find if you will be able to meet.

Given a start hour and end hour for your free time and a start hour and end hour of your friend free time, write a function that return True or False if you will be able to meet with your friend.

The Hours will be given the 24 h format.

For example :

13 - 15 and 14 - 16 ==> true
0 - 3 and 23 - 2 ==> true
1 - 3 and 23 - 24 ==> false

#include <cmath>

static float hourToRad(int hour)
{
  return (float) hour * (M_PI / 12.0);
};

static bool willTheyMeet(
  int startHour1, 
  int endHour1, 
  int startHour2,
  int endHour2)
{
  auto a1 = hourToRad(startHour1);
  auto a2 = hourToRad(endHour1);
  auto b1 = hourToRad(startHour2);
  auto b2 = hourToRad(endHour2);
  
  if (a1 == b2 || a2 == b1)
                return false;
  float da = (a2 - a1) / 2.0;
  float db = (b2 - b1) / 2.0;
  float ma = (a2 + a1) / 2.0;
  float mb = (b2 + b1) / 2.0;
  float cda = cos(da);
  float cdb = cos(db);
  return cos(ma - b1) >= cda ||
         cos(ma - b2) >= cda ||
         cos(mb - a1) >= cdb ||
         cos(mb - a2) >= cdb;
};

Introduction

My place of work changes all the time, and my Nokia Brick doesn't support Google Maps.
I need to find the fastest way to work through a variety of different locations - and I need user-friendly instructions that can be read out, since I can't look away from the road.

Your job in this kumite is to take an array (the map), and work out the fastest way from the hotel ('h'), to the office ('o') through the streets given. Driveable roads are represented by blankspace, and the map (and roads) are outlined by dashes ('-'). Then, compute some directions to take me there!

IF THERE IS NO POSSIBLE WAY TO GET TO THE OFFICE, RETURN "dont bother"

In the words of a great poet,

"The journey, not the arrival, matters." - T.S. Eliot

Tips

  • You can assume that when I start, I am facing north.
  • You can assume that there will be a route faster than the others.
  • You can assume that the arrays will be the same length.
  • I must travel onto the hotel.
  • I will start on the outline of the map - moving into the map is an included step.
  • You cannot assume that the I will start at the bottom of the map.

Result

You must return an array with strings inside, that can only be of the following:

"turn left", "turn right", "drive forward"

Bear in mind that "turning left" or "turning right" does not move me anywhere - I have car that rotates on the spot ;)

Example

[['-','o','-','-','-'],
 ['-',' ',' ',' ','-'],
 ['-',' ','-',' ','-'],       This should return ["drive forward", "turn left", "drive forward", "turn right",
 ['-',' ','-',' ','-'],       "drive forward", "drive forward", "drive forward", "drive forward"]
 ['-',' ',' ',' ','-'],
 ['-','-','h','-','-']]
 

Sidenotes

I have made extensive efforts to make sure this kumite is original. If this is not the case, and you cannot personally retire it, please drop a comment with a link to that kumite, and I would be happy to rectify my mistake.

Also, I am aware this is setup much like a kata - but unfortunately with a kata you need a working solution, which I can't make! Maybe when this is functional, it can be converted into a Kata. ;)

def directions(map):
    return ["drive forward"]