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.
lambda goes brr
#include <ctype.h> #include <stdbool.h> #include <stdlib.h> #include <string.h> char * caesar_cypher (const char *input, int amount, bool reversed, bool encode, bool ignore_special_chars, bool match_case) { char *res = malloc (strlen(input) + 1); char *p = res; amount = (amount % 26) * (2 * (encode ^ reversed) - 1); for (; *input; input++) { char c = *input; if (!isalpha (c)) { if (!ignore_special_chars) *p++ = c; continue; } char s = ((toupper (c) + amount - 39) % 26) + 65; *p++ = match_case && islower (c) ? tolower (s) : s; } return *p = '\0', res; }
func caesarCypher(_ input: String,amount: Int,reversed: Bool = false,encode: Bool = true,ignoreSpecialChars: Bool = false,matchCase: Bool = true) -> String {let alphabet = Array("ABCDEFGHIJKLMNOPQRSTUVWXYZ")return input.map { character inlet char = Character(character.uppercased())guard alphabet.contains(char) else {return ignoreSpecialChars ? "" : String(char)}var newIndex = alphabet.firstIndex(of: char)!switch encode {case true:newIndex += (reversed ? -amount : amount)case false:newIndex += (reversed ? amount : -amount)- #include <ctype.h>
- #include <stdbool.h>
- #include <stdlib.h>
- #include <string.h>
- char *
- caesar_cypher (const char *input, int amount, bool reversed, bool encode,
- bool ignore_special_chars, bool match_case)
- {
- char *res = malloc (strlen(input) + 1);
- char *p = res;
- amount = (amount % 26) * (2 * (encode ^ reversed) - 1);
- for (; *input; input++)
- {
- char c = *input;
- if (!isalpha (c))
- {
- if (!ignore_special_chars)
- *p++ = c;
- continue;
- }
(newIndex < 0) ? (newIndex += 26) : ()(newIndex >= 26) ? (newIndex -= 26) : ()return (char.isLowercase && matchCase)? alphabet[newIndex].lowercased() : alphabet[newIndex].uppercased()}.joined()- char s = ((toupper (c) + amount - 39) % 26) + 65;
- *p++ = match_case && islower (c) ? tolower (s) : s;
- }
- return *p = '\0', res;
- }
#include <criterion/criterion.h> #include <stdbool.h> char *caesar_cypher (const char *input, int amount, bool reversed, bool encode, bool ignore_special_chars, bool match_case); Test (fixed_tests, simple) { const char *input = "The Quick Brown Fox Jumps Over The Lazy Dog"; char *submited = caesar_cypher (input, 11, false, true, true, false); const char *expected = "ESPBFTNVMCZHYQZIUFXADZGPCESPWLKJOZR"; cr_assert_str_eq (submited, expected); free (submited); }
import XCTest- #include <criterion/criterion.h>
- #include <stdbool.h>
class SolutionTest: XCTestCase {static var allTests = [("Fixed Tests", fixedTests),]- char *caesar_cypher (const char *input, int amount, bool reversed, bool encode,
- bool ignore_special_chars, bool match_case);
func fixedTests() {let input = "The Quick Brown Fox Jumps Over The Lazy Dog"XCTAssertEqual(caesarCypher(input, amount: 11, ignoreSpecialChars: true, matchCase: false), "ESPBFTNVMCZHYQZIUFXADZGPCESPWLKJOZR")}}XCTMain([testCase(SolutionTest.allTests)])- Test (fixed_tests, simple)
- {
- const char *input = "The Quick Brown Fox Jumps Over The Lazy Dog";
- char *submited = caesar_cypher (input, 11, false, true, true, false);
- const char *expected = "ESPBFTNVMCZHYQZIUFXADZGPCESPWLKJOZR";
- cr_assert_str_eq (submited, expected);
- free (submited);
- }
you could have done better, I was not impressed
#import random <<< weak # Global variable to keep track of the current index _dice_index = 0 def dice(): global _dice_index choices = ["1", "2", "3", "3", "4", "5"]#icons are wack - change my mind! result = choices[_dice_index] _dice_index = (_dice_index + 1) % len(choices) return result
import random- #import random <<< weak
- # Global variable to keep track of the current index
- _dice_index = 0
- def dice():
return random.choice(["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"])- global _dice_index
- choices = ["1", "2", "3", "3", "4", "5"]#icons are wack - change my mind!
- result = choices[_dice_index]
- _dice_index = (_dice_index + 1) % len(choices)
- return result
import codewars_test as test # TODO Write tests import solution # or from solution import example @test.it("Basic tests") def basic_tests(): valid = ["1", "2", "3", "3", "4", "5"] # roll 100 times for _ in range(100): result = dice() test.expect(result in valid, f"Got {result} but expected one of {valid}")
- import codewars_test as test
- # TODO Write tests
- import solution # or from solution import example
- @test.it("Basic tests")
- def basic_tests():
valid = ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"]- valid = ["1", "2", "3", "3", "4", "5"]
- # roll 100 times
- for _ in range(100):
- result = dice()
- test.expect(result in valid, f"Got {result} but expected one of {valid}")
Return True if argument is greater than 2. Otherwise, make the argument greater than 2
Sinnlos..
hehe
// Since Node 10, we're using Mocha. // You can use 'chai' for assertions. const chai = require ("chai"); const assert = chai.assert; // Uncoment the following line to disable truncatting failure message dor deep equals, do: // chai.config.truncateThreshold = 0; // Since Node 12, we no longer include assertions from our department custom test frameworks by default // Uncoment the following to use the old assetions: // const Test = require ("@codewars/test-compat"); describe("solution", function() { it ("should test for something", function () { // Test assetrtEquals(1+1+2); // assert.strictEqual(1+1+2); }); });
// Since Node 10, we're using Mocha. // You can use `chai` for assertions. const chai = require("chai"); const assert = chai.assert; // Uncomment the following line to disable truncating failure messages for deep equals, do: // chai.config.truncateThreshold = 0; // Since Node 12, we no longer include assertions from our deprecated custom test framework by default. // Uncomment the following to use the old assertions: // const Test = require("@codewars/test-compat"); describe("Solution", function() { it("should test for something", function() { // Test.assertEquals(1 + 1, 2); // assert.strictEqual(1 + 1, 2); }); });