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.
def prime(x): if x <= 1: return False for i in range(2,int(x/2)): if x % i is 0: return False return True
- def prime(x):
counter = 0for i in range(1,x):- if x <= 1:
- return False
- for i in range(2,int(x/2)):
- if x % i is 0:
counter += 1if counter is 0:return Trueelse:return False- return False
- return True
test.assert_equals(prime(12345),False) test.assert_equals(prime(36),False) test.assert_equals(prime(36),False) test.assert_equals(prime(0), False) test.assert_equals(prime(1), False) test.assert_equals(prime(2), True) test.assert_equals(prime(7), True) test.assert_equals(prime(13), True) test.assert_equals(prime(97), True) test.assert_equals(prime(29), True)
- test.assert_equals(prime(12345),False)
- test.assert_equals(prime(36),False)
- test.assert_equals(prime(36),False)
- test.assert_equals(prime(0), False)
- test.assert_equals(prime(1), False)
- test.assert_equals(prime(2), True)
- test.assert_equals(prime(7), True)
- test.assert_equals(prime(13), True)
- test.assert_equals(prime(97), True)
- test.assert_equals(prime(29), True)
public class AbbreviateTwoWords { public static String abbrevName(String name) { return name.replaceAll("[^A-Z\\s]","").replaceAll("\\s","."); } }
- 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.replaceAll("[^A-Z\\s]","").replaceAll("\\s",".");
- }
- }
your solution in one line
# only works with strings, but five times faster than the original solution import re def unique_in_order(iterable): return re.findall(r'(.)(?!\1)', iterable)
- # only works with strings, but five times faster than the original solution
- import re
- 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- return re.findall(r'(.)(?!\1)', iterable)
# speed test results (original): 7849ms / 7793ms / 7844ms # speed test results (now): 1503ms / 1516ms / 1471ms for i in range(100000): unique_in_order('AAAABBBCCCCCCCCCCCCCCCCCCCCCCCCDAABBB'), ['A','B','C','D','A','B'] test.assert_equals(unique_in_order('AAAABBBCCCCCCCCCCCCCCCCCCCCCCCCDAABBB'), ['A','B','C','D','A','B']) test.assert_equals(unique_in_order('44444455321111'), ['4','5','3','2','1']) test.assert_equals(unique_in_order('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBCCCCCCCCCCCCCCCCCCCCCCCCDAABBB'), ['A','B','C','D','A','B']) test.assert_equals(unique_in_order('AAAABBBCCCCCCCCCCCCCCCCCCCCCCCCDAABBB'), ['A','B','C','D','A','B']) test.assert_equals(unique_in_order('AAAABBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDAABBB'), ['A','B','C','D','A','B']) test.assert_equals(unique_in_order('AAAABBBCCCCCCCCCCCCCCCCCCCCCCCCDAABBB'), ['A','B','C','D','A','B']) test.assert_equals(unique_in_order('AAAABBBCCCCCCCCCCCsssCCCCCCCCCCCCCDAABBB'), ['A','B','C','s', 'C','D','A','B'])
- # speed test results (original): 7849ms / 7793ms / 7844ms
- # speed test results (now): 1503ms / 1516ms / 1471ms
- for i in range(100000):
- unique_in_order('AAAABBBCCCCCCCCCCCCCCCCCCCCCCCCDAABBB'), ['A','B','C','D','A','B']
- test.assert_equals(unique_in_order('AAAABBBCCCCCCCCCCCCCCCCCCCCCCCCDAABBB'), ['A','B','C','D','A','B'])
- test.assert_equals(unique_in_order('44444455321111'), ['4','5','3','2','1'])
- test.assert_equals(unique_in_order('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBCCCCCCCCCCCCCCCCCCCCCCCCDAABBB'), ['A','B','C','D','A','B'])
- test.assert_equals(unique_in_order('AAAABBBCCCCCCCCCCCCCCCCCCCCCCCCDAABBB'), ['A','B','C','D','A','B'])
- test.assert_equals(unique_in_order('AAAABBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDAABBB'), ['A','B','C','D','A','B'])
- test.assert_equals(unique_in_order('AAAABBBCCCCCCCCCCCCCCCCCCCCCCCCDAABBB'), ['A','B','C','D','A','B'])
- test.assert_equals(unique_in_order('AAAABBBCCCCCCCCCCCsssCCCCCCCCCCCCCDAABBB'), ['A','B','C','s', 'C','D','A','B'])
BEHOLD THE ALMIGHTY :
public class myWorld{ public static void printArray(int[] arr){ for(int i : arr) System.out.println(i); } }
- public class myWorld{
public void printArray(int[] arr){for(int i = 0; i < arr.length; i++){System.out.println(arr[i]);}- public static void printArray(int[] arr){
- for(int i : arr)
- System.out.println(i);
- }
- }
import org.junit.Test; import static org.junit.Assert.assertEquals; import org.junit.runners.JUnit4; public class SolutionTest { @Test public void test(){ myWorld.printArray(new int[]{3,2,1,4,5}); } }
- import org.junit.Test;
- import static org.junit.Assert.assertEquals;
- import org.junit.runners.JUnit4;
- public class SolutionTest {
public void printArray(int[] arr) {int pass1 = arr[0];int pass2 = arr[1];System.out.println(pass1);System.out.println(pass2);// etc.......//- @Test
- public void test(){
- myWorld.printArray(new int[]{3,2,1,4,5});
- }
- }
with(` `) with(0b1101110100) ({}).__proto__[toString(length)]=_=>toString(length)
//return string that says the word ok- with(` `)
- with(0b1101110100)
- ({}).__proto__[toString(length)]=_=>toString(length)
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")
- });
- });
It works once every hour :)
function returnhundred() { return new Date().getMinutes() + new Date().getMinutes() + new Date().getMinutes() + new Date().getMinutes(); }
- function returnhundred() {
return 10 ** 2;- return new Date().getMinutes() + new Date().getMinutes() + new Date().getMinutes() + new Date().getMinutes();
- }
Test.assertEquals(returnhundred(), 100)
// 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.Test.assertEquals(returnhundred(),100)- Test.assertEquals(returnhundred(), 100)