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.
// Exercício 1 const titulo = "UOL - O melhor conteúdo"; // Exercício 2 const tags = [] tags.push(...['A', 'B']); // Exercício 3 let descricao = "Em 1999"; descricao += " em São Paulo"; // Exercício 4 const materia = {titulo: "Barão de Limeira"}; materia.titulo = "Alameda " + materia.titulo; // Exercício 5 for (let i = 10; i--;) { console.log(i); } // Exercício 6 for (const tag of ['A', 'B']) { console.log(tag); } // Exercício 7 for (var j = [].length; j--;) {} if (j === -1) { console.log('Não encontrei'); } // Exercício 8 let a = 123; { a *= 2; } console.log(a); // Exercício 9 let state = 'active'; function stop() { state = 'paused'; } stop(); // Exercício 10 const TRUE = !0;
- // Exercício 1
var titulo = "UOL - O melhor conteúdo";- const titulo = "UOL - O melhor conteúdo";
- // Exercício 2
var tags = []- const tags = []
- tags.push(...['A', 'B']);
- // Exercício 3
var descricao = "Em 1999";- let descricao = "Em 1999";
- descricao += " em São Paulo";
- // Exercício 4
var materia = {titulo: "Barão de Limeira"};- const materia = {titulo: "Barão de Limeira"};
- materia.titulo = "Alameda " + materia.titulo;
- // Exercício 5
for (var i = 10; i--;) {- for (let i = 10; i--;) {
- console.log(i);
- }
- // Exercício 6
for (var tag of ['A', 'B']) {- for (const tag of ['A', 'B']) {
- console.log(tag);
- }
- // Exercício 7
- for (var j = [].length; j--;) {}
- if (j === -1) {
- console.log('Não encontrei');
- }
- // Exercício 8
var a = 123;- let a = 123;
- {
- a *= 2;
- }
- console.log(a);
- // Exercício 9
var state = 'active';- let state = 'active';
- function stop() {
- state = 'paused';
- }
- stop();
- // Exercício 10
var TRUE = !0;- const TRUE = !0;
I wonder what this does?
(defn goes-before? [val1 val2] (<= val1 val2))
;; bubble: list of number -> list of number
;; This was originally racket code,
;; so it used 'car' and 'cdr' instead of 'first' and 'next'
;; Why can't clojure keep my theming?
(defn bubble [tanks]
;; I'm using nested if statements here because I want to use let
(if (or (nil? tanks) (nil? (next tanks)))
(cons tanks '(false))
(let* [truck (first tanks) convoy (next tanks) jeep (first convoy)]
(if (goes-before? truck jeep)
(let [debrief (bubble convoy)] (cons (cons truck (first debrief)) (next debrief)))
(cons (cons jeep (first (bubble (cons truck (next convoy))))) '(true))
)
)
)
)
;; bubble-sort: list of number -> list of number
(defn bubble-sort [l]
(let [bubbly (bubble l)]
(if (first (next bubbly))
(bubble-sort (first bubbly))
(first bubbly)
)))
(prn (bubble-sort (list 5 4 3 2 1)))
function dumbRockPaperScissors(player1, player2) { if((player1 === 'Rock' && player2 === 'Scissors') || (player1 === 'Scissors' && player2 === 'Paper') || (player1 === 'Paper' && player2 === 'Rock')){ return 'Player 1 wins';} else if((player2 === 'Rock' && player1 === 'Scissors') || (player2 === 'Scissors' && player1 === 'Paper') || (player2 === 'Paper' && player1 === 'Rock')){ return 'Player 2 wins';} else{ return 'Draw'; } }
- function dumbRockPaperScissors(player1, player2) {
if(player1 == "Rock" && player2 == "Paper"){return "Player 2 wins";}else if(player1 == "Rock" && player2 == "Scissors" ){return "Player 1 wins";}else if(player1 == "Scissors" && player2 == "Paper"){return "Player 1 wins";}else if(player1 == "Scissors" && player2 == "Rock"){return "Player 2 wins";}else if(player1 == "Paper" && player2 == "Scissors"){return "Player 2 wins";}else if(player1 == "Paper" && player2 == "Rock"){return "Player 1 wins";- if((player1 === 'Rock' && player2 === 'Scissors') ||
- (player1 === 'Scissors' && player2 === 'Paper') ||
- (player1 === 'Paper' && player2 === 'Rock')){ return 'Player 1 wins';}
- else if((player2 === 'Rock' && player1 === 'Scissors') ||
- (player2 === 'Scissors' && player1 === 'Paper') ||
- (player2 === 'Paper' && player1 === 'Rock')){ return 'Player 2 wins';}
- else{
- return 'Draw';
- }
else if(player1 == "Paper" && player2 == "Paper"){return "Draw";}else if(player1 == "Rock" && player2 == "Rock"){return "Draw";}else if(player1 == "Scissors" && player2 == "Scissors"){return "Draw";}- }
The algorithm works with constant complexity O(n), memory is limited to O(n)
const firstNonRepeatingCharacter = (str) => { let stack = str.split('') let deletedChars = '' let result; while(stack.length > 0) { let current = stack.shift() if (!deletedChars.includes(current)) { if (!stack.includes(current)) { result = current; break; } else { deletedChars += current; } } } return result || null; };
- const firstNonRepeatingCharacter = (str) => {
for (let i = 0; i < str.length; i++) {let seenDuplicate = false;for (let j = 0; j < str.length; j++) {if (str[i] === str[j] && i !== j) {seenDuplicate = true;break;}}if (!seenDuplicate) {return str[i];}- let stack = str.split('')
- let deletedChars = ''
- let result;
- while(stack.length > 0) {
- let current = stack.shift()
- if (!deletedChars.includes(current)) {
- if (!stack.includes(current)) {
- result = current;
- break;
- } else {
- deletedChars += current;
- }
- }
- }
return null; // return null if no unique character is found- return result || null;
- };
// def multiply (a,b): // return a * b const multiply = (a, b) => a * b;
// # def multiply (a,b):// # return a * b- // def multiply (a,b):
- // return a * b
multiply = (a, b) => a * b;- const multiply = (a, b) => a * b;
const { strictEqual } = require("chai").assert; describe("Basic Tests", function () { function doTest(num1, num2, expected) { const actual = multiply(num1, num2); strictEqual(actual, expected, `For ${num1} & ${num2}\n`); } it("should multiply correctly", function () { doTest(0, 5, 0); doTest(1, 5, 5); doTest(2, 5, 10); doTest(-2, 5, -10); }); });
// 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");- const { strictEqual } = require("chai").assert;
describe("Solution", function() {it("should test for something", function() {// Test.assertEquals(1 + 1, 2);// assert.strictEqual(1 + 1, 2);- describe("Basic Tests", function () {
- function doTest(num1, num2, expected) {
- const actual = multiply(num1, num2);
- strictEqual(actual, expected, `For ${num1} & ${num2}\n`);
- }
- it("should multiply correctly", function () {
- doTest(0, 5, 0);
- doTest(1, 5, 5);
- doTest(2, 5, 10);
- doTest(-2, 5, -10);
- });
- });
Силиванова
function нечетное(число) { if (число%2!=0){ return true } else { return false } } function sumNechet(a, b) { let sum=0 for(slag=a;slag<=b;slag++){ if (нечетное(slag)){ sum+=slag } } return (sum) }
function sumNechet(a, b) {}- function нечетное(число) {
- if (число%2!=0){
- return true
- }
- else {
- return false
- }
- }
- function sumNechet(a, b) {
- let sum=0
- for(slag=a;slag<=b;slag++){
- if (нечетное(slag)){
- sum+=slag
- }
- }
- return (sum)
- }