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.
open Preloaded; let fib = (n) => { let rec fib_aux = (n, a, b) => if (n <= 0) { a; } else { fib_aux(n - 1, b, a +@ b); } fib_aux(n, big_int_of_int(0), big_int_of_int(1)) |> string_of_big_int; }; let fib64 = (n) => { // Open Int64 locally open Int64; let rec fib_aux = (n, a, b) => if (n <= 0) { a; } else { fib_aux(n - 1, b, add(a, b)); } fib_aux(n, zero, one) |> to_string; };
- open Preloaded;
- let fib = (n) => {
- let rec fib_aux = (n, a, b) =>
- if (n <= 0) { a; }
- else { fib_aux(n - 1, b, a +@ b); }
- fib_aux(n, big_int_of_int(0), big_int_of_int(1))
- |> string_of_big_int;
- };
- let fib64 = (n) => {
- // Open Int64 locally
- open Int64;
- let rec fib_aux = (n, a, b) =>
- if (n <= 0) { a; }
- else { fib_aux(n - 1, b, add(a, b)); }
- fib_aux(n, zero, one)
- |> to_string;
- };
open Jest; describe("fib", () => { open Expect; test("n = 1", () => expect(Solution.fib(1)) |> toBe("1")); test("n = 10", () => expect(Solution.fib(10)) |> toBe("55")); test("n = 100", () => expect(Solution.fib(100)) |> toBe("354224848179261915075")); test("n = 200", () => expect(Solution.fib(200)) |> toBe("280571172992510140037611932413038677189525")); test("n = 1", () => expect(Solution.fib64(1)) |> toBe("1")); test("n = 10", () => expect(Solution.fib64(10)) |> toBe("55")); test("n = 90", () => expect(Solution.fib64(90)) |> toBe("2880067194370816120")); test("n = 92", () => expect(Solution.fib64(92)) |> toBe("7540113804746346429")); // n = 93 fails // test("n = 93", () => // expect(Solution.fib64(93)) |> toBe("12200160415121876738")); });
- open Jest;
- describe("fib", () => {
- open Expect;
- test("n = 1", () =>
- expect(Solution.fib(1)) |> toBe("1"));
- test("n = 10", () =>
- expect(Solution.fib(10)) |> toBe("55"));
- test("n = 100", () =>
- expect(Solution.fib(100)) |> toBe("354224848179261915075"));
- test("n = 200", () =>
- expect(Solution.fib(200)) |> toBe("280571172992510140037611932413038677189525"));
- test("n = 1", () =>
- expect(Solution.fib64(1)) |> toBe("1"));
- test("n = 10", () =>
- expect(Solution.fib64(10)) |> toBe("55"));
- test("n = 90", () =>
- expect(Solution.fib64(90)) |> toBe("2880067194370816120"));
- test("n = 92", () =>
- expect(Solution.fib64(92)) |> toBe("7540113804746346429"));
- // n = 93 fails
- // test("n = 93", () =>
- // expect(Solution.fib64(93)) |> toBe("12200160415121876738"));
- });
We have n piles of apples, and we want to get them together.
Once a time we can combine two piles of apples with a and b apples seperately together, using a+b forces. We want to know the minimum forces we use to combine all piles of apples together.
Input:
apple(n,lst)
where lst contains n numbers representing the number of apples in each pile
// TODO: Replace examples and use TDD development by writing your own tests Describe(any_group_name_you_want) { It(should_do_something) { int a[]={1,2,3,4}; Assert::That(apple(4,a), Equals(19)); int b[]={3,5,2,1,4}; Assert::That(apple(5,b), Equals(33)); } };
- // TODO: Replace examples and use TDD development by writing your own tests
- Describe(any_group_name_you_want)
- {
- It(should_do_something)
- {
- int a[]={1,2,3,4};
- Assert::That(apple(4,a), Equals(19));
- int b[]={3,5,2,1,4};
- Assert::That(apple(5,b), Equals(33));
- }
- };
function getChange(allPrice,youMoney) { return parseFloat((youMoney-allPrice).toFixed(1)); }
function getChange(allPrice,youMoney){return parseFloat((1-(allPrice/youMoney)).toFixed(4))*youMoney;- function getChange(allPrice,youMoney) {
- return parseFloat((youMoney-allPrice).toFixed(1));
- }
describe("Solution", function() { it("should test for something", function() { Test.assertEquals(getChange(4,10), 6); Test.assertEquals(getChange(4,100), 96); Test.assertEquals(getChange(4.5,100), 95.5); Test.assertEquals(getChange(3.5,5), 1.5); Test.assertEquals(getChange(3.8,5), 1.2); Test.assertEquals(getChange(3.7435,8.124444), 4.4); // assert.strictEqual(1 + 1, 2); }); });
- describe("Solution", function() {
- it("should test for something", function() {
- Test.assertEquals(getChange(4,10), 6);
- Test.assertEquals(getChange(4,100), 96);
- Test.assertEquals(getChange(4.5,100), 95.5);
- Test.assertEquals(getChange(3.5,5), 1.5);
- Test.assertEquals(getChange(3.8,5), 1.2);
- Test.assertEquals(getChange(3.7435,8.124444), 4.4);
- // assert.strictEqual(1 + 1, 2);
- });
- });
num -> string -> array -> [sort(), reverse()] -> string -> num
JS is fun!