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.
class Odd def odd(n) n % 2 == 1 end end
public static class Kata{public static bool IsOdd(int input){return ((input % 10 == 1) || (input % 10 == 3) || (input % 10 == 5) || (input % 10 == 7) || (input % 10 == 9));}}- class Odd
- def odd(n)
- n % 2 == 1
- end
- end
describe Odd do it 'should return false if number is even' do expect(subject.odd(2)).to eq(false) expect(subject.odd(16)).to eq(false) expect(subject.odd(19482475932)).to eq(false) end it 'should return true if number is odd' do expect(subject.odd(3)).to eq(true) expect(subject.odd(15)).to eq(true) expect(subject.odd(18409270457)).to eq(true) end end
namespace Solution {using NUnit.Framework;using System;// TODO: Replace examples and use TDD by writing your own tests[TestFixture]public class SolutionTest{[Test]public void MyTest(){Assert.AreEqual(true, Kata.IsOdd(1));Assert.AreEqual(false, Kata.IsOdd(2));Assert.AreEqual(true, Kata.IsOdd(13));Assert.AreEqual(false, Kata.IsOdd(18284));}}}- describe Odd do
- it 'should return false if number is even' do
- expect(subject.odd(2)).to eq(false)
- expect(subject.odd(16)).to eq(false)
- expect(subject.odd(19482475932)).to eq(false)
- end
- it 'should return true if number is odd' do
- expect(subject.odd(3)).to eq(true)
- expect(subject.odd(15)).to eq(true)
- expect(subject.odd(18409270457)).to eq(true)
- end
- end
Find maximum element of a list in Haskell
module FindMaxNumber where find_max :: Ord a => [a] -> a find_max = maximum
def find_max(arr):return 0- module FindMaxNumber where
- find_max :: Ord a => [a] -> a
- find_max = maximum
module FindMaxNumberSpec where import Test.Hspec import FindMaxNumber spec = do describe "Test find_max" $ do it "find_max [1,2,3,4,5]" $ do find_max [1, 2, 3, 4, 5] `shouldBe` 5
# TODO: Replace examples and use TDD by writing your own tests# These are some of the methods available:# test.expect(boolean, [optional] message)# test.assert_equals(actual, expected, [optional] message)# test.assert_not_equals(actual, expected, [optional] message)- module FindMaxNumberSpec where
# You can use Test.describe and Test.it to write BDD style test groupingstest.assert_equals(find_max([1, 2, 3, 4, 5]), 5)- import Test.Hspec
- import FindMaxNumber
- spec = do
- describe "Test find_max" $ do
- it "find_max [1,2,3,4,5]" $ do
- find_max [1, 2, 3, 4, 5] `shouldBe` 5
const main = () => { let a = [1, 2, 3]; let b = [4, 5, 6]; let c = [7, 8, 9]; // converter para ES6 let d = [...a, ...b, ...c]; return d.join(','); }
- const main = () => {
- let a = [1, 2, 3];
- let b = [4, 5, 6];
- let c = [7, 8, 9];
// converter para ES6var d = a.concat(b).concat(c);- // converter para ES6
- let d = [...a, ...b, ...c];
- return d.join(',');
- }
class Component { constructor(dom) { this.dom = dom; } onCreate() { console.log('onCreate from parent class'); return 'missing'; } static on(event, callback) { callback(); } async emit(event, data) {} } class Title extends Component { onCreate() { super.onCreate(); return 'super!'; } }
- class Component {
- constructor(dom) {
- this.dom = dom;
- }
- onCreate() {
- console.log('onCreate from parent class');
- return 'missing';
- }
- static on(event, callback) {
- callback();
- }
- async emit(event, data) {}
- }
- class Title extends Component {
- onCreate() {
- super.onCreate();
- return 'super!';
- }
- }
class Component { constructor(dom){ this.dom = dom; } onCreate() { return this.dom; } } const comp = new Component(); comp.onCreate();
function Component(dom) {this.dom = dom;this.onCreate = function() {- class Component {
- constructor(dom){
- this.dom = dom;
- }
- onCreate() {
- return this.dom;
- }
}- }
- const comp = new Component();
- comp.onCreate();
let results = [ {materia: {conteudo: {titulo: 'São Paulo'}}, tags: [1, 2, 3]}, {materia: {conteudo: {}}, tags: [3, 2]}, {materia: {conteudo: {titulo: 'Rio de Janeiro'}}, tags: [3, 2]}, ]; // for (const result of results) { // let titulo = result.materia.conteudo.titulo || 'Brasil for (const {materia: {conteudo: {titulo = 'Brasil'}}} of results) { console.log(titulo); }
- let results = [
- {materia: {conteudo: {titulo: 'São Paulo'}}, tags: [1, 2, 3]},
- {materia: {conteudo: {}}, tags: [3, 2]},
- {materia: {conteudo: {titulo: 'Rio de Janeiro'}}, tags: [3, 2]},
- ];
for (const result of results) {let titulo = result.materia.conteudo.titulo || 'Brasil';- // for (const result of results) {
- // let titulo = result.materia.conteudo.titulo || 'Brasil
- for (const {materia: {conteudo: {titulo = 'Brasil'}}} of results) {
- console.log(titulo);
- }