Begin a new Kumite
Search
About
  • Filter by Language:
  • 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.

function calcGPA(string) {
  string = string.split(' ');
  let total = 0
  string.forEach(x => {
    if (x >= 90) return total += 4
     if (x >= 80) return total += 3
     if (x >= 70) return total += 2
     if (x >= 60) return total += 1
  })
  return total / string.length
}

New user, sorry if I'll only use the title and description

This is around 6 kyu i think

Inputs are always array

function returnLastNonRepNum(arr) {
  for (let i = arr.length ; i > 0; i-- ) {
    if (typeof(arr[i]) === 'number' && arr.indexOf(arr[i]) === arr.lastIndexOf(arr[i])) {
        return arr[i]
        }
  }
}
let arr = [ 1, 'a', 6, 'c', 9, 9, 66, 's', 66, '6'];
console.log(returnLastNonRepNum(arr))
// should output 6

Simulating the UEFA Champions League Draw. Code is long because of the team data.

/*2021.12.13. Draw of the UEFA Champions League quarter-finals. 
This was a joke with a bad software. Decided to code a better one.

There are 16 teams, 8 group-winners and 8 runners-up.
A runner-up team is drawed first from the 8. It is paired with a gruop-winner. 
There are 2 rules:
it can not go from the same group
it can not have the same nationality.
After the pairing, the paired teams are taken out of the list before the next draw.
*/

/*database: 2 arrays of objects*/ 
const groupWinners = [
    {
        name: "Manchester City",
        group: "A",
        nationality: "English"
    },
    {
        name: "Liverpool",
        group: "B",
        nationality: "English"
    },
    {
        name: "Ajax Amsterdam",
        group: "C",
        nationality: "Dutch"
    },
    {
        name: "Real Madrid",
        group: "D",
        nationality: "Spanish"
    },
    {
        name: "Bayern Munich",
        group: "E",
        nationality: "German"
    },
    {
        name: "Manchester United",
        group: "F",
        nationality: "English"
    },
    {
        name: "Lille",
        group: "G",
        nationality: "French"
    },
    {
        name: "Juventus",
        group: "H",
        nationality: "Italian"
    }
];

const runnersUp = [
    {
        name: "Paris Saint-Germain",
        group: "A",
        nationality: "French"
    },
    {
        name: "Atletico Madrid",
        group: "B",
        nationality: "Spanish"
    },
    {
        name: "Sporting CP",
        group: "C",
        nationality: "Portuguese"
    },
    {
        name: "Internazionale",
        group: "D",
        nationality: "Italian"
    },
    {
        name: "Benfica",
        group: "E",
        nationality: "Portuguese"
    },
    {
        name: "Villarreal",
        group: "F",
        nationality: "Spanish"
    },
    {
        name: "FC Salzburg",
        group: "G",
        nationality: "Austrian"
    },
    {
        name: "Chelsea",
        group: "H",
        nationality: "English"
    }
];

console.log("\n");
console.log("WELCOME IN THE DRAW OF THE UEFA CHAMPIONS LEAGUE QUARTER-FINALS!");
console.log("\n");

/*arrays containing teams which can be still drawed and an array for the pairings*/
let groupWinnersToDraw = [...groupWinners];
let runnersUpToDraw = [...runnersUp];
let pairings = [];

/*while there are teams to draw */
while (runnersUpToDraw.length > 0) {
    /*choose a random team from runnersUpToDraw */
    let index = Math.floor(Math.random()*(runnersUpToDraw.length));
    let teamToFace = runnersUpToDraw[index];
    /*updating the runnersUpToDraw array*/ 
    runnersUpToDraw = runnersUpToDraw.slice(0, index).concat(runnersUpToDraw.slice(index+1, runnersUpToDraw.length));

    console.log("Team to face:", teamToFace.name, teamToFace.group, teamToFace.nationality);
    console.log("\n");
    
    /*selecting the potential opponents */
    let potentialOpponents = groupWinnersToDraw.filter(team => 
        (team.group != teamToFace.group && team.nationality != teamToFace.nationality) 
    );
    console.log("Potential opponents:")
    potentialOpponents.forEach(team => console.log(team.name, team.group, team.nationality));
    console.log("\n");
    
    /*choose a random team from potentialOpponents */
    let anotherIndex = Math.floor(Math.random()*(potentialOpponents.length));
    let opponent = potentialOpponents[anotherIndex];
    console.log("The opponent is:", opponent.name, opponent.group, opponent.nationality);
    console.log("\n");

    /*updating the groupWinnersToDraw array*/ 
    let yetAnotherIndex = 0;
    for (let i = 0; i < groupWinnersToDraw.length; i++) {
        if (groupWinnersToDraw[i].name == opponent.name) {
            yetAnotherIndex = i;
        }
    }
    groupWinnersToDraw = groupWinnersToDraw.slice(0, yetAnotherIndex).concat(groupWinnersToDraw.slice(yetAnotherIndex+1, groupWinnersToDraw.length));
    console.log("Remaining group-winners:")
    groupWinnersToDraw.forEach(team => console.log(team.name));
    console.log("\n");

    /*save the pairings */
    let drawing = [];
    drawing.push(teamToFace);
    drawing.push(opponent);
    pairings.push(drawing);
}

/*log the draw */

console.log("THE QUARTER-FINALS: ");
console.log("\n");
pairings.forEach(pair => {
    console.log(pair[0].name, pair[0].group, pair[0].nationality, "  vs  ", 
    pair[1].name, pair[1].group, pair[1].nationality );
});

The Tower of Hanoi is a mathematical puzzle. It consists of three poles and a number of disks of different sizes which can slide onto any poles. The puzzle starts with the disk in a neat stack in ascending order of size in one pole, the smallest at the top thus making a conical shape. The objective of the puzzle is to move all the disks from one pole (say ‘source pole’) to another pole (say ‘destination pole’) with the help of the third pole (say auxiliary pole).

The puzzle has the following two rules:
1. You can’t place a larger disk onto a smaller disk
2. Only one disk can be moved at a time

https://en.wikipedia.org/wiki/Tower_of_Hanoi

using System.Collections.Generic;
using System.Diagnostics;

public class TowerOfHanoi
{
    public static int Tower(int numOfDisks)
    {
        return 0;
    }

    private static int Tower(int n, string source, string aux, string dest, Dictionary<int, int> cache)
    {
        return 0;
    }

}

Your goal is simple: To find the one character that doesn't fit in to the string.

Example:

aaaaabaaaaa

should return "b"

No trick questions! Take it at face value.

package oddoneout

fun oddOneOut(s: String): String {
    
    var odd = 0
    var same = 0
    
    var keepTrack = s[0]
    
    var sameTracker = ""
    var oddTracker = ""
    
    for (i in s.indices) {
        if (s[i] == keepTrack) {
            same += 1
            sameTracker += s[i]
        } else {
            odd += 1
            oddTracker += s[i]
        }
    }
    
    if (odd < 2) {
        return oddTracker 
    } else {
        return sameTracker
    }
    
}
Regular Expressions
Declarative Programming
Advanced Language Features
Fundamentals
Strings
Arrays

You need to somehow turn RegExp into an array of strings, for example:

/fo?x([ea]s)?|do?gs?/

it should turn out something like this:

["fox", "fx", "foxes", "foxas", "dog", "dogs", "dg", "dgs"]

If \d occurs in RexExp, it must generate an array from 0 to 9

if \w then generates an array from a to z

if \n or \t then ignores

and if there is a + somewhere, then the function should return Infinity

function regexpToStringArray(regexp) {
  
}

In this kata there will be two inputs.Your task is to determine whether relative numbers are or are not, if are relative numbers then return relative and if not non relative.

Relative numbers - integers that have no common divisors other than 1 and itself.

Example: relativeNumbers(8, 9):
The number 8 has 2,4 divisors;
The number 9 has 3 divisor;
Due to the fact that the numbers 8 and 9 do not have common divisors, they are relative numbers

function relativeNumbers(a, b) {
  let arrOne = [];
  let arrTwo = [];
  for (let i = 2; i < 10; i++) {
    if (a % i === 0 && a !== i) {
      arrOne.push(i);
    }
    if(b % i === 0 && b !== i){
        arrTwo.push(i)
    }
  }
  for(let i = 0; i < arrOne.length; i++){
    for(let j = 0; j < arrTwo.length; j++){
        if(arrOne[i] === arrTwo[j]){
            return "non relative"
        }else return "relative"
    }
  }
}

Your job is to write a function which increments a string, to create a new string.

If the string already ends with a number, the number should be incremented by 1.
If the string does not end with a number. the number 1 should be appended to the new string.
Examples:

foo -> foo1

foobar23 -> foobar24

foo0042 -> foo0043

foo9 -> foo10

foo099 -> foo100

Attention: If the number has leading zeros the amount of digits should be considered.

function incrementString (strng) {
  // return incrementedString
}
bruh

The function takes three parameters a, b, c. Using these parameters - find the discriminant.

The function should return an array of solutions of the form [solution1, solution2].

discriminant > 0 ? return [solution1, solution2];

discriminant = 0 ? return [solution1];

discriminant < 0 ? return ['no solutions'];

Ex: x^2−3x+2
result: [2, 1]

Note: solution1 should be greater than solution2 :)

const discriminant = (a, b, c) => {
  let result = [];
  let D = b*b - 4*a*c;
  D < 0 ? result.push('no solutions') : result.push((b*(-1) + Math.sqrt(D)) / (2*a));
  D > 0 ? result.push((b*(-1) - Math.sqrt(D)) / (2*a)) : 'xD';
  return result;
}