Start a new Kumite

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

Writing a simple test
Use of a ternary condition

Code
Diff
  • const checkDistance = d => d < 3 ? 'ALMOST THERE' : 'yuh gotta wait a little';
    • function checkDistance(distance) {
    • const threeDistance = 3;
    • const almostMsg = 'ALMOST THERE';
    • const litleMsg = 'yuh gotta wait a little';
    • return distance < threeDistance ? almostMsg : litleMsg;
    • }
    • console.log(checkDistance(1))
    • const checkDistance = d => d < 3 ? 'ALMOST THERE' : 'yuh gotta wait a little';
Code
Diff
  • const calculateFine = (limit: number) => (speed: number) => { const diff = speed - limit; if (diff >= 10 && diff < 40) return 1000/((3 ** (3-~~(diff%100/10)) + 1)) return (diff < 10) ? 0 : 500; } export const checkIfAtOrBelowLimit = (acceleration: number[], limit: number) => acceleration.map(calculateFine(limit)); 
    • const calculateFine = (limit: number) => (speed: number) => {
    • const diff = speed - limit;
    • if (diff >= 30) return 500;
    • if (diff >= 20) return 250;
    • if (diff >= 10) return 100;
    • return 0;
    • if (diff >= 10 && diff < 40) return 1000/((3 ** (3-~~(diff%100/10)) + 1))
    • return (diff < 10) ? 0 : 500;
    • }
    • export const checkIfAtOrBelowLimit = (acceleration: number[], limit: number) => acceleration.map(calculateFine(limit));
Code
Diff
  • import random import string def cursed_world(): target = "hello world" letters = [random.choice(string.ascii_lowercase + ' ') for _ in range(11)] generation = 0 while True: generation += 1 score = sum(letters[i] == target[i] for i in range(11)) if score == 11: return "".join(letters) new_letters = letters[:] for i in range(11): if new_letters[i] != target[i]: if random.random() < 0.3: new_letters[i] = random.choice(string.ascii_lowercase + ' ') letters = new_letters 
    • import random
    • import string
    • def cursed_world():
    • s = ""
    • for i in range(11):
    • s += chr(round((1/362880) * (2206*i**10 - 110153*i**9 + 2354280*i**8 - 28131474*i**7 + 205908150*i**6 - 950715465*i**5 + 2745571940*i**4 - 4732336636*i**3 + 4357651104*i**2 - 1601282592*i + 37739520)))
    • return s
    • target = "hello world"
    • letters = [random.choice(string.ascii_lowercase + ' ') for _ in range(11)]
    • generation = 0
    • while True:
    • generation += 1
    • score = sum(letters[i] == target[i] for i in range(11))
    • if score == 11:
    • return "".join(letters)
    • new_letters = letters[:]
    • for i in range(11):
    • if new_letters[i] != target[i]:
    • if random.random() < 0.3:
    • new_letters[i] = random.choice(string.ascii_lowercase + ' ')
    • letters = new_letters