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.
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) -> 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"
- }
- }
import XCTest // XCTest Spec Example: // TODO: replace with your own tests (TDD), these are just how-to examples to get you started class SolutionTest: XCTestCase { static var allTests = [ ("Test Example", testExample), ] func testExample() { XCTAssertEqual(gradeCalc(100), "A") XCTAssertEqual(gradeCalc(96), "A") XCTAssertEqual(gradeCalc(90), "A") XCTAssertEqual(gradeCalc(30), "F") XCTAssertEqual(gradeCalc(70), "C") XCTAssertEqual(gradeCalc(79), "C") XCTAssertEqual(gradeCalc(80), "B") XCTAssertEqual(gradeCalc(-27), "Not a grade") XCTAssertEqual(gradeCalc(127), "Not a grade") } } XCTMain([ testCase(SolutionTest.allTests) ])
- import XCTest
- // XCTest Spec Example:
- // TODO: replace with your own tests (TDD), these are just how-to examples to get you started
- class SolutionTest: XCTestCase {
- static var allTests = [
- ("Test Example", testExample),
- ]
- func testExample() {
let actual = 1XCTAssertEqual(actual, 1)- XCTAssertEqual(gradeCalc(100), "A")
- XCTAssertEqual(gradeCalc(96), "A")
- XCTAssertEqual(gradeCalc(90), "A")
- XCTAssertEqual(gradeCalc(30), "F")
- XCTAssertEqual(gradeCalc(70), "C")
- XCTAssertEqual(gradeCalc(79), "C")
- XCTAssertEqual(gradeCalc(80), "B")
- XCTAssertEqual(gradeCalc(-27), "Not a grade")
- XCTAssertEqual(gradeCalc(127), "Not a grade")
- }
- }
- XCTMain([
- testCase(SolutionTest.allTests)
- ])
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
Test.assert_equals(divisible_by_3(0), True) Test.assert_equals(divisible_by_3(1), False) Test.assert_equals(divisible_by_3(2), False) Test.assert_equals(divisible_by_3(3), True) Test.assert_equals(divisible_by_3(3 * 10**100), True) Test.assert_equals(divisible_by_3(3 * 10**100 + 1), False) Test.assert_equals(divisible_by_3(3 * 10**100 + 2), False) Test.assert_equals(divisible_by_3(3 * 10**100 + 3), True)
# test suite author: theguy678- Test.assert_equals(divisible_by_3(0), True)
- Test.assert_equals(divisible_by_3(1), False)
- Test.assert_equals(divisible_by_3(2), False)
- Test.assert_equals(divisible_by_3(3), True)
import mathfrom random import randintTest.describe("Basic Tests")Test.assert_equals(divisibility_by_3(454), False)Test.assert_equals(divisibility_by_3(222), True)Test.assert_equals(divisibility_by_3(10593), True)Test.describe("Complex Test")Test.assert_equals(divisibility_by_3(0), True)Test.assert_equals(divisibility_by_3(-10593), True)Test.describe("Random Test")for x in range(100):num = randint(-10000, 10000)Test.assert_equals(divisibility_by_3(num), str(num/3).endswith(".0"))- Test.assert_equals(divisible_by_3(3 * 10**100), True)
- Test.assert_equals(divisible_by_3(3 * 10**100 + 1), False)
- Test.assert_equals(divisible_by_3(3 * 10**100 + 2), False)
- Test.assert_equals(divisible_by_3(3 * 10**100 + 3), True)
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.141592653589793circle_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
# orcircle_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]]
from math import pi for x in [12, 0.57, 1, 0, 3.14]: Test.assert_approx_equals(circle_area(x), pi * x**2) for x in [0.16, 1, 12, 0, 3.14]: Test.assert_approx_equals(circle_circumference(x), pi * x * 2)
import mathfrom random import randint- from math import pi
Test.describe("Basic Tests")Test.assert_equals(circle_area(12), 452.39)Test.assert_equals(circle_area(0.57), 1.02)Test.assert_equals(circle_area(1), 3.14)Test.assert_equals(circle_cir(0.16), 1.01)Test.assert_equals(circle_cir(1), 6.28)Test.assert_equals(circle_cir(12), 75.4)- for x in [12, 0.57, 1, 0, 3.14]:
- Test.assert_approx_equals(circle_area(x), pi * x**2)
Test.describe("Complex Test")Test.assert_equals(circle_area(0), 0)Test.assert_equals(circle_area(3.14), 30.97)Test.assert_equals(circle_cir(0), 0)Test.assert_equals(circle_cir(3.14), 19.73)Test.describe("Random Test")for x in range(100):if x % 2 == 0:num = randint(500, 1000)Test.assert_equals(circle_area(num), round(math.pi*num*num, 2))else:num = randint(500, 1000)Test.assert_equals(circle_cir(num), round(math.pi*num*2, 2))- for x in [0.16, 1, 12, 0, 3.14]:
- Test.assert_approx_equals(circle_circumference(x), pi * x * 2)