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
function find_unique_items(array1, array2) 
{
  //Find the unique elements from two arrays
  return [1,2,4,6,8]
}

So basically turn an integer into a table of all the numbers from zero to that number

def int_to_table(num):
    tab = []
    for x in range(num + 1):
        tab.append(x)
    print(tab)
    return tab
import codewars_test as test
# TODO Write tests
import solution # or from solution import example

# test.assert_equals(actual, expected, [optional] message)
@test.describe("Example")
def test_group():
    @test.it("test case")
    def test_case():
        test.assert_equals(int_to_table(9), [0,1,2,3,4,5,6,7,8,9])
        test.assert_equals(int_to_table(7), [0,1,2,3,4,5,6,7])
        test.assert_equals(int_to_table(4), [0,1,2,3,4])
public class FizzBuzz
{
    public string GetOutput(int number) {
      // Fizz buzz is a popular computer science interview question.  
      // The function above is given a number - if the number is
      // divisible by 3, return "fizz", if it's divisible by 5, 
      // return "buzz", if not divisble by 3 or 5 - return the
      // number itself.
      return "0";
    }
}

Description:
Your task is to remove every third char in a string,
using a zero based index

Example:

removeEverySecond('hello world'); // 'heloword'
removeEverySecond('how you doing') // 'howyoudoin'

function removeEveryThird(str) {
  // Remove the third character from every work in the string
  // using a zero based index
  return 'heloword';
}

Description:
Given an expression as a string, calculate its value. For example, given the string "1+2+3", return 6.

Order of operations should be respected: multiplication happens before addition.

Possible avenues for future exploration:

Adding support for subtraction and division
Stripping whitespace
Adding support for brackets

using System;
using System.Linq;

public class ArtihmeticParser
{
  public static int Evaluate(string input)
  {
    return input.Split("+").Select(EvaluateProduct).Aggregate(0,(a,b) => a+b);
  }
  
  private static int EvaluateProduct(string input)
  {
    return input.Split("*").Select(EvaluateInteger).Aggregate(1,(a,b) => a*b);
  }
  
  private static int EvaluateInteger(string input)
  {
    return int.Parse(input);
  }
}
// Write a project that demonstrates inheritance in C#

Guess my age according to my birth year if we live in 2021 :)

const myAge = function(birthYear) {
  // Your Code Here
  
}
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 );
});