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.
Welcome to kaju bakery,
Kaju bakery deals with large number of orders of cake. So to handle the cake demand we need a function that takes in the number of servings of cake required and price of cake in dollar and returns the total price for that cake.
We also impose tax of 1$ so keep that in mind too
Have the function named deliver and return the total price customer has to pay in the counter.
also check if the number of servings <= 0 then just return zero.
def price(servings, price): if servings >0: cost = servings * price cost += 1 return cost else: return 0
def multiply_and_add_one(a, b):c = a * bc += 1return c- def price(servings, price):
- if servings >0:
- cost = servings * price
- cost += 1
- return cost
- else:
- return 0
import codewars_test as test from solution import price @test.describe("Kaju bakery") def _(): @test.it("Basic tests") def test_case(): test.assert_equals(price(2, 3), 7) test.assert_equals(price(4, 5), 21) test.assert_equals(price(0, 10), 0) test.assert_equals(price(-1, 5), 0)
- import codewars_test as test
from solution import multiply_and_add_one- from solution import price
@test.describe("Multiply and Add One Tests")- @test.describe("Kaju bakery")
- def _():
- @test.it("Basic tests")
- def test_case():
test.assert_equals(multiply_and_add_one(2, 3), 7)test.assert_equals(multiply_and_add_one(4, 5), 21)test.assert_equals(multiply_and_add_one(0, 10), 1)test.assert_equals(multiply_and_add_one(-1, 5), -4)- test.assert_equals(price(2, 3), 7)
- test.assert_equals(price(4, 5), 21)
- test.assert_equals(price(0, 10), 0)
- test.assert_equals(price(-1, 5), 0)
#include <string> #include <string_view> std::string reverse_string(std::string_view word){ return {word.rbegin(), word.rend()}; }
- #include <string>
- #include <string_view>
using namespace std;string reverse_string(string_view word){- std::string reverse_string(std::string_view word){
- return {word.rbegin(), word.rend()};
- }
I was bored.
#include <stdlib.h> int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; } int unique_sum(const int arr[/*size*/], size_t size) { int r = 0; qsort(arr, size, sizeof(int), cmp); for (size_t i = 0; i < size; ) { if ((i == 0 || arr[i] != arr[i - 1]) && (i == size - 1 || arr[i] != arr[i + 1])) r += arr[i]; for (int v = arr[i]; i < size && arr[i] == v; i++); } return r; }
#include <bits/stdc++.h>using namespace std;int unique_sum(const vector<int>& n) {auto nums = n;sort(nums.begin(), nums.end(), [](int a, int b) {return a < b;});int sum = 0;for(size_t i = 0; i < nums.size(); i++) {if(nums[i] == nums[i+1] || nums[i] == nums[i-1]) {continue;} else {sum += nums[i];}- #include <stdlib.h>
- int cmp(const void *a, const void *b)
- {
- return *(int *)a - *(int *)b;
- }
- int unique_sum(const int arr[/*size*/], size_t size)
- {
- int r = 0;
- qsort(arr, size, sizeof(int), cmp);
- for (size_t i = 0; i < size; )
- {
- if ((i == 0 || arr[i] != arr[i - 1]) &&
- (i == size - 1 || arr[i] != arr[i + 1]))
- r += arr[i];
- for (int v = arr[i]; i < size && arr[i] == v; i++);
- }
return sum;- return r;
- }
// TODO: Replace examples and use TDD by writing your own tests. The code provided here is just a how-to example. #include <criterion/criterion.h> #include <stdlib.h> int unique_sum(const int[], size_t); Test(unique_sum_of_numbers, should_do_something) { cr_assert_eq(unique_sum((const int[]){1, 2, 3, 2}, 4), 4); cr_assert_eq(unique_sum((const int[]){1, 1, 2, 3}, 4), 5); cr_assert_eq(unique_sum((const int[]){-1, -1, 0, 1}, 4), 1); } Test(unique_sum_of_numbers, should_do_something_other) { cr_assert_eq(unique_sum((const int[]){}, 0), 0); cr_assert_eq(unique_sum((const int[]){5, 5, 5, 5}, 4), 0); cr_assert_eq(unique_sum((const int[]){10, 20, 30, 20, 10}, 5), 30); cr_assert_eq(unique_sum((const int[]){1, 2, 3, 4, 5}, 5), 15); cr_assert_eq(unique_sum((const int[]){-5, -5, 0, 5, 5}, 5), 0); cr_assert_eq(unique_sum((const int[]){-1, 2, -1, 3, 4, 2}, 6), 7); cr_assert_eq(unique_sum((const int[]){1, 2, 3, 4, 5, 1, 2, 3}, 8), 9); cr_assert_eq(unique_sum((const int[]){100, 200, 300, 300, 200, 100}, 6), 0); }
// TODO: Replace examples and use TDD by writing your own tests- // TODO: Replace examples and use TDD by writing your own tests. The code provided here is just a how-to example.
Describe(unique_sum_of_numbers)- #include <criterion/criterion.h>
- #include <stdlib.h>
- int unique_sum(const int[], size_t);
- Test(unique_sum_of_numbers, should_do_something)
- {
- cr_assert_eq(unique_sum((const int[]){1, 2, 3, 2}, 4), 4);
- cr_assert_eq(unique_sum((const int[]){1, 1, 2, 3}, 4), 5);
- cr_assert_eq(unique_sum((const int[]){-1, -1, 0, 1}, 4), 1);
- }
- Test(unique_sum_of_numbers, should_do_something_other)
- {
It(should_do_something){Assert::That(unique_sum({1,2,3,2}), Equals(4));Assert::That(unique_sum({1,1,2,3}), Equals(5));Assert::That(unique_sum({-1,-1,0,1}), Equals(1));};It(should_do_something_other){Assert::That(unique_sum({}), Equals(0));Assert::That(unique_sum({5, 5, 5, 5}), Equals(0));Assert::That(unique_sum({10, 20, 30, 20, 10}), Equals(30));Assert::That(unique_sum({1, 2, 3, 4, 5}), Equals(15));Assert::That(unique_sum({-5, -5, 0, 5, 5}), Equals(0));Assert::That(unique_sum({-1, 2, -1, 3, 4, 2}), Equals(7));Assert::That(unique_sum({1, 2, 3, 4, 5, 1, 2, 3}), Equals(9));Assert::That(unique_sum({100, 200, 300, 300, 200, 100}), Equals(0));}};- cr_assert_eq(unique_sum((const int[]){}, 0), 0);
- cr_assert_eq(unique_sum((const int[]){5, 5, 5, 5}, 4), 0);
- cr_assert_eq(unique_sum((const int[]){10, 20, 30, 20, 10}, 5), 30);
- cr_assert_eq(unique_sum((const int[]){1, 2, 3, 4, 5}, 5), 15);
- cr_assert_eq(unique_sum((const int[]){-5, -5, 0, 5, 5}, 5), 0);
- cr_assert_eq(unique_sum((const int[]){-1, 2, -1, 3, 4, 2}, 6), 7);
- cr_assert_eq(unique_sum((const int[]){1, 2, 3, 4, 5, 1, 2, 3}, 8), 9);
- cr_assert_eq(unique_sum((const int[]){100, 200, 300, 300, 200, 100}, 6), 0);
- }