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.
function testPassword(password){ let hasUppercase = false; let hasSpecial = false; let isLong = false; password.split('').forEach((char) => { let charCode = char.charCodeAt(); if((charCode > 32 && charCode < 48) || (charCode > 57 && charCode < 64)){ hasSpecial = true; } else if(charCode > 64 && charCode < 91){ hasUppercase = true; } }); if(password.length > 7){ isLong = true; } return hasUppercase && isLong && hasSpecial; }
- function testPassword(password){
var cap = false;var spec = false;var number = false;var temp;- let hasUppercase = false;
- let hasSpecial = false;
- let isLong = false;
for(i=0;i<password.length;i++){temp = password[i].charCodeAt();if(temp > 32 && temp < 48){spec = true;} else if(temp > 57 && temp < 64){spec = true;} else if(temp > 64 && temp < 91){cap = true;- password.split('').forEach((char) => {
- let charCode = char.charCodeAt();
- if((charCode > 32 && charCode < 48) || (charCode > 57 && charCode < 64)){
- hasSpecial = true;
- }
- else if(charCode > 64 && charCode < 91){
- hasUppercase = true;
- }
}- });
//see if the password is over 8 digits longif(password.length > 7){number = true;}//provide final answerif(cap && number && spec){return true;} else {return false;- if(password.length > 7){
- isLong = true;
- }
- return hasUppercase && isLong && hasSpecial;
- }
class Locale { sayHelloTo(whoever){ throw new Error("Not implemented"); } } class EnglishLocale extends Locale { sayHelloTo(whoever){ return `hello ${whoever}`; } } class PirateLocale extends Locale { sayHelloTo(whoever){ return `yar ${whoever}`; } } class BinaryLocale extends EnglishLocale { sayHelloTo(whoever) { let msg = super.sayHelloTo(whoever); return this.txtToBin(msg); } txtToBin(text) { let result = []; for(let character of text){ let binaryArr = this.numberToBinaryArray(character.charCodeAt()); result = result.concat(binaryArr); } return result.join(""); } numberToBinaryArray(number) { let result = []; while(number > 0){ let bit = Math.floor(number % 2) != 0 ? 1 : 0; result.unshift(bit) number = Math.floor(number / 2); } while(result.length != 8) { result.unshift(0); } return result; } } const GREET_LANG = { ENGLISH: new EnglishLocale(), PIRATE: new PirateLocale(), BINARY: new BinaryLocale(), } const hello = (whoever, lang=GREET_LANG.ENGLISH) => lang.sayHelloTo(whoever);
// Declare new languages here and map them in parseGreeting() functionconst GREET_LANG = {ENGLISH: 0,PIRATE: 1,BINARY: 2- class Locale {
- sayHelloTo(whoever){
- throw new Error("Not implemented");
- }
- }
function numberToBinaryArray(number) {let result = [];while(number > 0){let bit = Math.floor(number % 2) != 0 ? 1 : 0;result.unshift(bit)number = Math.floor(number / 2);}while(result.length != 8)result.unshift(0);return result;- class EnglishLocale extends Locale {
- sayHelloTo(whoever){
- return `hello ${whoever}`;
- }
- }
function txtToBin(text) {let result = [];for(let character of text){let binaryArr = numberToBinaryArray(character.charCodeAt());result = result.concat(binaryArr);}return result.join("");- class PirateLocale extends Locale {
- sayHelloTo(whoever){
- return `yar ${whoever}`;
- }
- }
function parseGreeting(lang) {switch(lang){case GREET_LANG.PIRATE:return 'yar';case GREET_LANG.BINARY:return txtToBin('hello');default:return 'hello';- class BinaryLocale extends EnglishLocale {
- sayHelloTo(whoever) {
- let msg = super.sayHelloTo(whoever);
- return this.txtToBin(msg);
- }
}- txtToBin(text) {
- let result = [];
- for(let character of text){
- let binaryArr = this.numberToBinaryArray(character.charCodeAt());
- result = result.concat(binaryArr);
- }
const parseWhoever = (whoever, lang) => lang == GREET_LANG.BINARY ? txtToBin(whoever) : whoever;- return result.join("");
- }
- numberToBinaryArray(number) {
- let result = [];
- while(number > 0){
- let bit = Math.floor(number % 2) != 0 ? 1 : 0;
- result.unshift(bit)
- number = Math.floor(number / 2);
- }
- while(result.length != 8) {
- result.unshift(0);
- }
- return result;
- }
- }
- const GREET_LANG = {
- ENGLISH: new EnglishLocale(),
- PIRATE: new PirateLocale(),
- BINARY: new BinaryLocale(),
- }
const hello = (whoever, lang=GREET_LANG.ENGLISH) => `${parseGreeting(lang)} ${parseWhoever(whoever, lang)}`;- const hello = (whoever, lang=GREET_LANG.ENGLISH) => lang.sayHelloTo(whoever);
describe("Solution", function(){ it("defaults to english", function(){ Test.assertEquals(hello('gotham'), "hello gotham"); }); it("responds in pirate when passed 'pirate' as the language", function(){ Test.assertEquals(hello('gotham', GREET_LANG.PIRATE), "yar gotham"); }); it("responds in real time binary when passed 'binary' as the language", function(){ Test.assertEquals(hello('gotham', GREET_LANG.BINARY), "011010000110010101101100011011000110111100100000011001110110111101110100011010000110000101101101"); }); });
- describe("Solution", function(){
- it("defaults to english", function(){
- Test.assertEquals(hello('gotham'), "hello gotham");
- });
- it("responds in pirate when passed 'pirate' as the language", function(){
- Test.assertEquals(hello('gotham', GREET_LANG.PIRATE), "yar gotham");
- });
it("responds in real time binarry when passed 'binary' as the language", function(){Test.assertEquals(hello('gotham', GREET_LANG.BINARY), "0110100001100101011011000110110001101111 011001110110111101110100011010000110000101101101");- it("responds in real time binary when passed 'binary' as the language", function(){
- Test.assertEquals(hello('gotham', GREET_LANG.BINARY), "011010000110010101101100011011000110111100100000011001110110111101110100011010000110000101101101");
- });
- });
Return the last character from a string.
In Rust return an Option<char>
.
?