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.

Code
Diff
  • func gradeCalc(_ score: Int) -> String {
      switch score {
      case 90...100: return "A"
      case 80..<90: return "B"
      case 70..<80: return "C"
      case 60..<70: return "D"
      case 0..<60: return "F"
      default: return "Not a grade"
      }
    }
    • func gradeCalc(_ score: Int) {
    • // Your Code under here
    • func gradeCalc(_ score: Int) -> String {
    • switch score {
    • case 90...100: return "A"
    • case 80..<90: return "B"
    • case 70..<80: return "C"
    • case 60..<70: return "D"
    • case 0..<60: return "F"
    • default: return "Not a grade"
    • }
    • }
Code
Diff
  • middle_string = lambda s: s[1:-1]
    • def middle_string(string):
    • return string[1:-1] if len(string) >= 3 else ""
    • middle_string = lambda s: s[1:-1]
Code
Diff
  • divisible_by_3 = lambda x: x == x // 3 * 3
    • divisibility_by_3 = lambda x: int(x / 3) == x / 3
    • divisible_by_3 = lambda x: x == x // 3 * 3
Code
Diff
  • from math import pi
    from operator import mul
    
    circle_area, circle_circumference = [(lambda op: (lambda r: pi * op(r, 2)))(f) for f in [pow, mul]]
    • PI = 3.141592653589793
    • circle_area = lambda r: round(PI * r ** 2, 2)
    • circle_cir = lambda r: round(PI * r * 2, 2)
    • from math import pi
    • from operator import mul
    • # or
    • circle_area = lambda r: round(__import__('math').pi * r ** 2, 2)
    • circle_cir = lambda r: round(__import__('math').pi * r * 2, 2)
    • circle_area, circle_circumference = [(lambda op: (lambda r: pi * op(r, 2)))(f) for f in [pow, mul]]
Code
Diff
  • dividedByThree = lambda n: n and not n % 3
    • dividedByThree = lambda n: n % 3 == 0 and n != 0
    • dividedByThree = lambda n: n and not n % 3