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

Convert a grade out of 100 to a letter grade.

Here are the criteria: used in assessing:

90-100 points = A

80-89 points = B

70-79 points = C

60-69 points = D

0-59 points = F

Make sure to return "Not a grade" for integers that are not equal to or between 100.

func gradeCalc(_ score: Int) {
  // Your Code under here
}

Make a calculator that can take in two integers and process any of the four basic operations. (Add, subtract, multiply, divide).

For the operation symbol, you need to turn the string that the person has inserted, and it should not be case sensitive.

Finally, it should return "Not a valid operation", if the operation that the user entered is not one of the four.

func calculator(_ int1: Int, _ operation: String, _ int2: Int) {
  //Code Here
}

Write a function that converts a base 10 number and returns binary (base 2).

Binary is consisted of zeros and ones only, and those make up the binary number.

Suppose that place value works the same.

func binaryConverter(_ input: Int) -> Int {
  //Your Code Here
  return input
}

Write a function that converts a base 10 number and returns binary (base 2).

Binary is consisted of zeros and ones only, and those make up the binary number.

Suppose that place value works the same.

func binaryConverter(_ input: Int) -> Int {
  //Your Code Here
  return input
}

Hailstone numbers are an interesting number series. The series is defined as follows:

  • Pick a number
  • If odd multiply by 3 add one
  • Else even divide by 2
  • Stop calculating the sequence when you reach 1

Different numbers reach one after a different number of steps.

e.g. Here are a few Hailstones that take a long time to reach 1

Hailstone 27 Steps: 112
Hailstone 54 Steps: 113
Hailstone 73 Steps: 116

Your code will need to be efficient with BigInt Lists

case class Hailstones (hailstoneStart : BigInt ) {
  private def getSequenceHighPerformance (currentHailstone : BigInt,  acc : List[BigInt]) : List[BigInt] = {
    if (currentHailstone == 1) currentHailstone::acc
    else if (currentHailstone.testBit(0)) getSequenceHighPerformance((currentHailstone << 1) + currentHailstone + 1, currentHailstone :: acc)
    else getSequenceHighPerformance(currentHailstone >> 1, currentHailstone :: acc)
  }

  val seq = getSequenceHighPerformance(hailstoneStart, List[BigInt]()).reverse
}

object Hailstones {
  def findSeq = Hailstones(18).seq
}

Given a radius of the circle,
return the area and the circumference of the circle in 2 decimal places.

function CircleArea(r){
return Number((Math.PI*r*r).toFixed(2));
}

function CircleCir(r){
return Number((Math.PI*r*2).toFixed(2));
}

Trying this

public class TestingRules {
  
    public static boolean doNothing(String braces) {
    
      return true;
    
    }
  
}

A wayward human has entered the Forest of the Lost- a forest renowned for having monsters of the worst variety.

Given the coordinates of the human, the coordinates of a monster, and the monster's attack span return whether the human is deciminated or if he lives to see another day.

ex. DeadOrAlive([3, 4], [3, 6], 1) == 'Alive!';

ex. DeadOrAlive([7, 6], [3, 6], 5) == 'Dead!';

Things to keep in mind:

  • The span will always be a whole number
  • Human and monster can have the same coordinates
String DeadOrAlive(List<int> human, List<int> monster, int span) {
  return ((monster[0] - human[0]).abs() <= span && (monster[1] - human[1]).abs() <= span) ? 'Dead!' : 'Alive!';
}

In this kumite, I will test if a number is divisible by 3 or not.

If it is I will return True.

Or, if it isn't and leaves a remainder I shall return False.

But the only gimmick to my own challenge is that I am not allowed to mod that directly. Is that possible?

(NOTE: I am allowed to use modulus for other purposes)

def divisibility_by_3(x):
    
    list_of_values = [int(d) for d in str(x)]
    summation = sum(list_of_values)
    if summation % 3 == 0:
        return True
    else:
        return False

For a given string return a substring without first and last elements of the string.
If the given string has less than three characters then return an empty string.

func substringWithoutFirstAndLastElement(_ string: String) -> String {
  guard string.count > 2 else { return "" }
  return String(String(string.dropFirst()).dropLast())
}