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.
fn is_odd(input: i32) -> bool { input % 2 == 1 }
public static class Kata{public static bool IsOdd(int input){return ((input % 10 == 1) || (input % 10 == 3) || (input % 10 == 5) || (input % 10 == 7) || (input % 10 == 9));}- fn is_odd(input: i32) -> bool {
- input % 2 == 1
- }
#[test] fn test() { assert!(is_odd(1)); assert!(is_odd(3)); assert!(!is_odd(2)); assert!(!is_odd(18284)); }
namespace Solution {using NUnit.Framework;using System;// TODO: Replace examples and use TDD by writing your own tests[TestFixture]public class SolutionTest{[Test]public void MyTest(){Assert.AreEqual(true, Kata.IsOdd(1));Assert.AreEqual(false, Kata.IsOdd(2));Assert.AreEqual(true, Kata.IsOdd(13));Assert.AreEqual(false, Kata.IsOdd(18284));}}}- #[test]
- fn test() {
- assert!(is_odd(1));
- assert!(is_odd(3));
- assert!(!is_odd(2));
- assert!(!is_odd(18284));
- }
function нечетное(число) { if (число%2!=0){ return true } else { return false } } function sumNechet(a, b) { let sum=0 for(slag=a;slag<=b;slag++){ if (нечетное(slag)){ sum+=slag } } return (sum) }
function sumNechet(a, b) {}- function нечетное(число) {
- if (число%2!=0){
- return true
- }
- else {
- return false
- }
- }
- function sumNechet(a, b) {
- let sum=0
- for(slag=a;slag<=b;slag++){
- if (нечетное(slag)){
- sum+=slag
- }
- }
}- return (sum)
- }
why not
function rps(player1, player2) { const rules = { 'rock': { killer: 'paper' }, 'paper': { killer: 'scissors' }, 'scissors': { killer: 'rock' }, }; if (rules[player1].killer === player2) { return 'Player 2 won!'; } if (rules[player2].killer === player1) { return 'Player 1 won!'; } return 'Draw!'; }
- function rps(player1, player2) {
return player1 == player2 ? 'Draw!' :player1 == 'rock' && player2 == 'scissors' ||player1 == 'scissors' && player2 == 'paper' ||player1 == 'paper' && player2 == 'rock' ? 'Player 1 won!' : 'Player 2 won!';- const rules = {
- 'rock': {
- killer: 'paper'
- },
- 'paper': {
- killer: 'scissors'
- },
- 'scissors': {
- killer: 'rock'
- },
- };
- if (rules[player1].killer === player2) {
- return 'Player 2 won!';
- }
- if (rules[player2].killer === player1) {
- return 'Player 1 won!';
- }
- return 'Draw!';
- }
fn decode(roman: &str) -> i32 { let mut number = 0; let mut numerals = roman.chars().peekable(); while let Some(curr) = numerals.next() { // if numerals.peek().is_some_and(|&next| value(curr) < value(next)) { // more elegant but currently unstable if Some(true) == numerals.peek().map(|&next| value(curr) < value(next)) { number -= value(curr); } else { number += value(curr); } } number } fn value(numeral: char) -> i32 { match numeral { 'I' => 1, 'V' => 5, 'X' => 10, 'L' => 50, 'C' => 100, 'D' => 500, 'M' => 1000, _ => panic!("Invalid roman numeral {numeral}"), } }
package kata- fn decode(roman: &str) -> i32 {
- let mut number = 0;
- let mut numerals = roman.chars().peekable();
- while let Some(curr) = numerals.next() {
- // if numerals.peek().is_some_and(|&next| value(curr) < value(next)) { // more elegant but currently unstable
- if Some(true) == numerals.peek().map(|&next| value(curr) < value(next)) {
- number -= value(curr);
- } else {
- number += value(curr);
- }
- }
- number
- }
func Decode(roman string) int {return 0- fn value(numeral: char) -> i32 {
- match numeral {
- 'I' => 1,
- 'V' => 5,
- 'X' => 10,
- 'L' => 50,
- 'C' => 100,
- 'D' => 500,
- 'M' => 1000,
- _ => panic!("Invalid roman numeral {numeral}"),
- }
- }
#[cfg(test)] mod tests { use super::decode; #[test] fn test() { assert_eq!(decode("XXI"), 21); assert_eq!(decode("I"), 1); assert_eq!(decode("IV"), 4); assert_eq!(decode("MMVIII"), 2008); assert_eq!(decode("MDCLXVI"), 1666); } }
package kata_testimport (. "github.com/onsi/ginkgo". "github.com/onsi/gomega". "codewarrior/kata")var _ = Describe("test roman to decimal converter", func() {It("should give decimal number from roman", func() {Expect(Decode("XXI")).To(Equal(21))- #[cfg(test)]
- mod tests {
- use super::decode;
})It("should give decimal number from roman", func() {Expect(Decode("I")).To(Equal(1))})It("should give decimal number from roman", func() {Expect(Decode("IV")).To(Equal(4))})It("should give decimal number from roman", func() {Expect(Decode("MMVIII")).To(Equal(2008))})It("should give decimal number from roman", func() {Expect(Decode("MDCLXVI")).To(Equal(1666))})})- #[test]
- fn test() {
- assert_eq!(decode("XXI"), 21);
- assert_eq!(decode("I"), 1);
- assert_eq!(decode("IV"), 4);
- assert_eq!(decode("MMVIII"), 2008);
- assert_eq!(decode("MDCLXVI"), 1666);
- }
- }