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.
panteliymasvs.WestwardLand9685 years ago
Prime Numbers - Inefficient!
public class AbbreviateTwoWords { public static String abbrevName(String name) { return (name.split(" ")[0].charAt(0) + "." + name.split(" ")[1].charAt(0)); } }
- public class AbbreviateTwoWords {
- public static String abbrevName(String name) {
String[] names = name.split(" ");return (names[0].charAt(0) + "." + names[1].charAt(0)).toUpperCase();- return (name.split(" ")[0].charAt(0) + "." + name.split(" ")[1].charAt(0));
- }
- }
Saladinvs.SV_developer6 years ago
Zu Chongzhi ratio
ES2015
Babel
'Cuase why not :)
/** * @param {Number} approximation - number of decimal places you're loojing for. * Shouldn't exceed 6 as Zu Chongzhi ratio are only valid until first 6 digits. * Is 2 by default. */ const pi = (approximation = 2) => /** Let's use [this guy's](https://en.wikipedia.org/wiki/Zu_Chongzhi) ratio to calc Pi */ (355 / 113).toFixed(approximation > 2 && approximation <= 6 ? approximation : 2)
const pi = () => {}pi()- /**
- * @param {Number} approximation - number of decimal places you're loojing for.
- * Shouldn't exceed 6 as Zu Chongzhi ratio are only valid until first 6 digits.
- * Is 2 by default.
- */
- const pi = (approximation = 2) =>
- /** Let's use [this guy's](https://en.wikipedia.org/wiki/Zu_Chongzhi) ratio to calc Pi */
- (355 / 113).toFixed(approximation > 2 && approximation <= 6 ? approximation : 2)
const assert = require('chai').assert describe("pi()", function () { it('Should equal 3.14 when called with no args', function () { const res = pi() console.log(`Call with no args:\n${res}`) assert.equal(res, 3.14, 'Call with no args') }) it('Should equal 3.1416 if 4 was passed', function () { const res = pi(4) console.log(`Call with approximation = 4:\n${res}`) assert.equal(res, 3.1416, 'Call with approximation = 4') }) it('Should equal 3.141593 if 6 was passed', function () { const res = pi(6) console.log(`Call with approximation = 6:\n${res}`) assert.equal(res, 3.141593, 'Call with approximation = 6') }) it('Should equal 3.14 whenever argument does not meet requirements to be 2 < arg <= 6', function () { const res = pi('abc') console.log(`Call with string passed as argument:\n${res}`) assert.equal(res, 3.14, 'Call with string passed as argument') }) });
- const assert = require('chai').assert
- describe("pi()", function () {
- it('Should equal 3.14 when called with no args', function () {
- const res = pi()
- console.log(`Call with no args:\n${res}`)
- assert.equal(res, 3.14, 'Call with no args')
- })
- it('Should equal 3.1416 if 4 was passed', function () {
- const res = pi(4)
- console.log(`Call with approximation = 4:\n${res}`)
- assert.equal(res, 3.1416, 'Call with approximation = 4')
- })
- it('Should equal 3.141593 if 6 was passed', function () {
- const res = pi(6)
- console.log(`Call with approximation = 6:\n${res}`)
- assert.equal(res, 3.141593, 'Call with approximation = 6')
- })
- it('Should equal 3.14 whenever argument does not meet requirements to be 2 < arg <= 6', function () {
- const res = pi('abc')
- console.log(`Call with string passed as argument:\n${res}`)
- assert.equal(res, 3.14, 'Call with string passed as argument')
- })
- });
art.schedrovvs.gavrashenko6 years ago
Insertion sort
function insertionSort(arr) { function sortingValues(a, b) { if (a > b) return 1; if (a == b) return 0; if (a < b) return -1; } return arr.sort(sortingValues); }
- function insertionSort(arr) {
// return sorted array- function sortingValues(a, b) {
- if (a > b) return 1;
- if (a == b) return 0;
- if (a < b) return -1;
- }
- return arr.sort(sortingValues);
- }
def unique_in_order(iterable): iterable = list(iterable) unique = [None] for x in iterable: if x != unique[-1]: unique.append(x) return unique[1:]
- def unique_in_order(iterable):
- iterable = list(iterable)
while 1==1:for x in range(len(iterable)):if iterable[x]==iterable[x-1]:del iterable[x]breakif x==len(iterable)-1:return iterable- unique = [None]
- for x in iterable:
- if x != unique[-1]:
- unique.append(x)
- return unique[1:]
Arrays
Data Types
Algorithms
Logic
Data
function pairs(arr) { const r = arr.join(' ').match(/-\d/g).filter(i => arr.includes(i[1] / 1)) /1 return [r, [Math.abs(r)]] }
function pairs(arr){let sorted = arr.sort();let length = arr.length;for (let i = 0; i < length; i++) {if (sorted.includes(arr[i] * -1)) {return [sorted[i], sorted[i] * -1];}}- function pairs(arr) {
- const r = arr.join(' ').match(/-\d/g).filter(i => arr.includes(i[1] / 1)) /1
- return [r,...[Math.abs(r)]]
- }
jerzy.burzekvs.valeri.burlacu6 years ago
Sum of the letters (ASCII)
class Kata{ public static String verifySum(String nameOne, String nameTwo) { if (nameOne == null || nameTwo == null) { return "NULL"; } return nameOne.chars().sum() == nameTwo.chars().sum() ? "TRUE" : "FALSE"; } }
- class Kata{
- public static String verifySum(String nameOne, String nameTwo) {
int[] sumOfNames = new int[]{0, 0};- if (nameOne == null || nameTwo == null) {
- return "NULL";
- }
for (int i = 0; i < nameOne.length(); i++){sumOfNames[0] += nameOne.charAt(i);}for (int i = 0; i < nameTwo.length(); i++){sumOfNames[1] += nameTwo.charAt(i);}return sumOfNames[0] == sumOfNames[1] ? "TRUE" : "FALSE";- return nameOne.chars().sum() == nameTwo.chars().sum() ? "TRUE" : "FALSE";
- }
- }
Luvexinavs.ReturnMaster6 years ago
Return ok
function ok() { return ok.name; }
//return string that says the word ok- function ok() {
- return ok.name;
- }
describe("Ok", function() { it("It should return ok.", function() { Test.assertEquals(ok(), "ok") }); });
// TODO: Add your tests here// Starting from Node 10.x, [Mocha](https://mochajs.org) is used instead of our custom test framework.// [Codewars' assertion methods](https://github.com/Codewars/codewars.com/wiki/Codewars-JavaScript-Test-Framework)// are still available for now.//// For new tests, using [Chai](https://chaijs.com/) is recommended.// You can use it by requiring:// const assert = require("chai").assert;// If the failure output for deep equality is truncated, `chai.config.truncateThreshold` can be adjusted.describe("Solution", function() {it("should test for something", function() {// Test.assertEquals(1 + 1, 2);// assert.strictEqual(1 + 1, 2);- describe("Ok", function() {
- it("It should return ok.", function() {
- Test.assertEquals(ok(), "ok")
- });
- });