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
import java.util.*;
public class Main {

    public static void main(String[] args) {
        int finalResult, month, date, year, flag = 0;
        String alphabeticalRepresentationOfMonth, suffix;
        System.out.println("Lets play a game");
        System.out.println("I'll guess your Birthday!");
        System.out.println("You just have to calculate stuffs");
        System.out.println("Note: You may need a calculator ");
        System.out.println("Okay, let's start");
        System.out.println("Follow every step carefully");
        System.out.println("Note: If you are using a calculator, press 'equal to' ('=') button after every step ");
        System.out.println("Step 1: Multiply your birth month by 5 ");
        System.out.println("Step 2: Add 6 to the result");
        System.out.println("Step 3: Multiply the result by 4");
        System.out.println("Step 4: Add 9 to the result");
        System.out.println("Step 5: Multiply the result by 5");
        System.out.println("Step 6: Add your birth date to the result");
        System.out.println("Now, enter the final result");
        Scanner sc = new Scanner(System.in);
        finalResult = sc.nextInt();
        finalResult -= 165;
        month = finalResult / 100;
        date = finalResult % 100;
        if (month == 1 || month == 3 || month == 5 || month == 7 || month ==8 || month == 10 || month == 12)
            if(date > 31) {
                System.out.println("Invalid Input");
                System.exit(0);
            }
        if(month == 4 || month == 6 || month == 9 || month == 11)
            if(date > 30){
                System.out.println("Invalid Input");
                System.exit(0);
            }


        switch(month){
            case 1:
                alphabeticalRepresentationOfMonth = "January";
                break;
            case 2: alphabeticalRepresentationOfMonth = "February";
                break;
            case 3: alphabeticalRepresentationOfMonth = "March";
                break;
            case 4: alphabeticalRepresentationOfMonth = "April";
                break;
            case 5: alphabeticalRepresentationOfMonth = "May";
                break;
            case 6: alphabeticalRepresentationOfMonth = "June";
                break;
            case 7: alphabeticalRepresentationOfMonth = "July";
                break;
            case 8: alphabeticalRepresentationOfMonth = "August";
                break;
            case 9: alphabeticalRepresentationOfMonth = "September";
                break;
            case 10: alphabeticalRepresentationOfMonth = "October";
                break;
            case 11: alphabeticalRepresentationOfMonth = "November";
                break;
            case 12: alphabeticalRepresentationOfMonth = "December";
                break;
            default:
                alphabeticalRepresentationOfMonth = "NULL";
                System.out.println("Invalid Input");
                System.exit(0);

        }
        if(date >= 10 && date <= 20 )
            suffix = "th";
        else {
            switch (date % 10) {
                case 1:
                    suffix = "st";
                    break;
                case 2:
                    suffix = "nd";
                    break;
                case 3:
                    suffix = "rd";
                    break;
                default:
                    suffix = "th";
                    break;
            }
        }
        System.out.println("Enter your age: ");
        year = 2019 - sc.nextInt();
        if(year % 4 == 0){
            if(year % 100 == 0){
                if(year % 400 == 0)
                    flag = 1;
                else
                    flag = 0;
            }
            else
                flag = 1;
        }
        else
            flag = 0;
        if(flag == 1 && month == 2)
            if (date > 29) {
                System.out.println("Invalid Input");
                System.exit(0);
            }
        if(flag == 0 && month == 2)
            if(date > 28){
                System.out.println("Inalid Input");
                System.exit(0);
            }
        System.out.println("Your birthday is on " + date + suffix + " "+ alphabeticalRepresentationOfMonth + ", " + year);

    }
}

Class for calculation with fractions

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


def lcm(a, b):
    return a * b // gcd(a, b)

class Fraction:

    def __init__(self, numerator, denominator):
        g = gcd(numerator, denominator)
        self.top = numerator // g
        self.bottom = denominator // g
    
    #Equality test
    
    def __eq__(self, other):
        first_num = self.top * other.bottom
        second_num = other.top * self.bottom
        return first_num == second_num
        
    def __add__(self, other):
        sum_denom = lcm(self.bottom, other.bottom)
        first_num = sum_denom * self.top // self.bottom
        second_num = sum_denom * other.top // other.bottom
        sum_num = first_num + second_num
        return Fraction(sum_num, sum_denom)
    
    def __sub__(self, other):
        dif_denom = lcm(self.bottom, other.bottom)
        first_num = sum_denom * self.top // self.bottom
        second_num = sum_denom * other.top // other.bottom
        dif_num = first_num - second_num
        return Fraction(dif_num, dif_denom)
        
    def __mul__(self, other):
        return Fraction(self.top * other.top, self.bottom * other.bottom)
        
    def __truediv__(self, other):
        return Fraction(self.top * other.bottom, self.bottom * other.top)
    
    def __str__(self):
        return str(self.top) + "/" + str(self.bottom)
// TODO: Create method objectFreeze which works the same as native Object.freeze.
// !IMPORTANT: You haven't use Object.freeze during your task

function objectFreeze(obj) {
  return Object.freeze(obj);
}

Write a function to add two numbers a and b

def sum(a,b):
    return a + b + 2 - 3 + 1

This code will take an input in (dd mm yyyy) format and check whether it is a valid date or not. Then it will display the day value and the name of the day of the week of that date.

SAMPLE INPUT:
Enter the Date:(DD MM YYYY): 31 12 2018

SAMPLE OUTPUT:
The day value is: 365 days and the day is Monday

import java.io.*;
class Date
{

public static void main()throws IOException
{

BufferedReader in=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter the Date:(DD MM YYYY): ");
String k=in.readLine();

int d=Integer.parseInt(k.substring(0,2)), c,m=Integer.parseInt(k.substring(3,5)), y=Integer.parseInt(k.substring(6)), i, a1[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
String a2[]={"Sunday","Monday","Tuesday","Tuesday","Wednesday","Thursday","Friday","Saturday"};

if((y%4==0 && y%100!=0)||y%400==0)
a1[2]=29;

if(m<1 || m>12 || d<1 || d>a1[m])
System.out.println("Invalid Date..............");
else
{
System.out.println("Valid Date.............");

for(i=1;i<m;i++)
d+=a1[i];

c=d;

for(i=1;i<y;i++)
if((i%4==0 && i%100!=0)||i%400==0)
d+=366;
else
d+=365;

System.out.println("The day value is: "+c+" days and thr day is "+a2[d%7]);
}
}
}

Rotate the elements in a 3-dimensional array 90 degrees to the left or to the right.

const rotateLeft = (arr) => {
  let retArr = [[],[],[]]
  for (let i = 0; i < arr.length; i++){
    for (let j = 0; j < arr[i].length; j++){
      retArr[i][j] = arr[j][arr.length - (i + 1)]
    }
  }
  return retArr
}

const rotateRight = (arr) => {
  let retArr = [[],[],[]]
  for (let i = 0; i < arr.length; i++){
    for (let j = 0; j < arr[i].length; j++){
      retArr[i][j] = arr[arr.length - (j + 1)][i]
    }
  }
  return retArr
}
anatollkoFailed Tests

Koliunua

console.log('hey hop')

At this task you need to use destructuring to find cookie strings into object 'findAllCookies'.
console.log(cookie1); must show 'cookie1'
console.log(cookie2); must show 'cookie2'

For example:

let findAllCookies = {
  here: {
    that: ['cookie']
  }
}

let {here: {that: [cookie]}} = findAllCookies;

console.log(cookie); //cookie
let findAllCookies = {
  level1: {
    hello: ['not here',
      {
        almost: 'cookie1'
      }
    ]
  },

  level2: [
    {
      where : [
        {},
        {},
        {
          here: [
            [
              {
                itsNotCookie: 'caakie'
              },
              {
                second:
                {
                  isItCookie: 'cookie2'
                }
              }
            ]
          ]
        }
      ]
    },
  ],
};

let /* Put your code */ = findAllCookies;
let /* Put your code */ = findAllCookies;

console.log(cookie1);
console.log(cookie2);

teste

using System;
public void main()
{}

A year is a leap year under the following conditions:

  1. year is divisible by 4.
  2. if year if divisible by 100, it must be divisible by 400

e.g. 1600 is a leap year, 1700 is not

Write a function to return whether the year is a leap year or not

bool isLeap(int year) {
  bool leap = true;
  if(year % 4 != 0){
    leap = false;
  } 
  if(year % 100 == 0 && year % 400 != 0) {
    leap = false;
  }
  return leap;
}