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.
from functools import reduce from operator import __mul__ def prod(numbers): return reduce(__mul__, numbers) if numbers else 0
- from functools import reduce
- from operator import __mul__
- def prod(numbers):
if numbers == []: return 0product = 1for number in numbers:product *= numberreturn product- return reduce(__mul__, numbers) if numbers else 0
Unnamedvs.StephenDonovan15 years ago
Next Fibonacci Number.
public class NthFib { public static final double phi = (1 + Math.sqrt(5))/2.0; public static int fib(int n) { return (int)Math.round(Math.pow(phi, n)/Math.sqrt(5)); } }
- public class NthFib {
- public static final double phi = (1 + Math.sqrt(5))/2.0;
public static final double psi = (1 - Math.sqrt(5))/2.0;- public static int fib(int n) {
return (int)((Math.pow(phi, n) - Math.pow(psi, n))/Math.sqrt(5));- return (int)Math.round(Math.pow(phi, n)/Math.sqrt(5));
- }
- }
SigmarSternvs.cihatdev5 years ago
Find the maximum number
const chai = require("chai"); const assert = chai.assert; describe("Find max number in array", function() { it("finds the max number in array",function() { assert.strictEqual(findMax([1, 2, 3, 4, 5]), 5) assert.strictEqual(findMax([1, 2, 3, -4, 5]), 5) assert.strictEqual(findMax([-1, -2, -3, -4, -5]), -1) }) })
Test.assertEquals(findMax([1, 2, 3, 4, 5]), 5)Test.assertEquals(findMax([1, 2, 3, -4, 5]), 5)Test.assertEquals(findMax([-1, -2, -3, -4, -5]), -1)- const chai = require("chai");
- const assert = chai.assert;
- describe("Find max number in array", function() {
- it("finds the max number in array",function() {
- assert.strictEqual(findMax([1, 2, 3, 4, 5]), 5)
- assert.strictEqual(findMax([1, 2, 3, -4, 5]), 5)
- assert.strictEqual(findMax([-1, -2, -3, -4, -5]), -1)
- })
- })
Mathematics
Algorithms
Logic
Numbers
int nbDaysInMonth(int n, bool m) { return n>7?31-n%2:n==2?31-3+m:31-1+n%2; //lets introduce some obfuscation:) }
int nbDaysInMonth(int n, bool m) {return n == 2 ? 28 + m : 30 + (n + (n > 7) & 1);- int nbDaysInMonth(int n, bool m) {
- return n>7?31-n%2:n==2?31-3+m:31-1+n%2; //lets introduce some obfuscation:)
- }
user354062vs.someone55 years ago
flip the number
Now with tests shipped.
const returnAscending = (args) => args.sort((a,b)=> a-b ).join('');
const returnAscending = (...args) => args.sort(function(a,b){return a-b }).join('');- const returnAscending = (...args) => args.sort((a,b)=> a-b ).join('');
const chai = require("chai"); const assert = chai.assert; describe("Solution", function() { it("should test for something", function() { assert.equal(returnAscending(1, 5, 4, 2, 3), '12345') }); });
// 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);- assert.equal(returnAscending(1, 5, 4, 2, 3), '12345')
- });
- });