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 mergeArrays(a, b, o=[]) { while (a.length && b.length) o.push((a[0] < b[0] ? a : b).shift()) return o.concat(a).concat(b) }
function mergeArrays(arrA, arrB) {const output = [];const arrAClone = [...arrA];const arrBClone = [...arrB];let nextSmallestA = arrAClone.shift();let nextSmallestB = arrBClone.shift();while (nextSmallestA !== undefined || nextSmallestB !== undefined) {if (nextSmallestA === undefined || nextSmallestB < nextSmallestA) {output.push(nextSmallestB);nextSmallestB = arrBClone.shift();} else {output.push(nextSmallestA);nextSmallestA = arrAClone.shift();}}return output;}- function mergeArrays(a, b, o=[]) {
- while (a.length && b.length)
- o.push((a[0] < b[0] ? a : b).shift())
- return o.concat(a).concat(b)
- }
// If the failure output for deep equality is truncated, `chai.config.truncateThreshold` can be adjusted. const assert = require("assert"); describe("mergeArray", function() { it("should work for 2 empty arrays", function() { const arr1 = []; const arr2 = []; const expected = []; const actual = mergeArrays(arr1, arr2); assert.deepStrictEqual(actual, expected); }); it("should work with a single empty array", function() { const arr1 = [1,3,5,7,9,11,13,15,17,19,200]; const arr2 = []; const expected = [1,3,5,7,9,11,13,15,17,19,200]; const actual = mergeArrays(arr1, arr2); console.log(actual) assert.deepStrictEqual(actual, expected); }); it("should work with large numbers", function() { const arr1 = [64649367165265, 274632412695799, 412877423124429, 516230628864647, 538837081813693, 746373629824209, 1692897751449627, 2270037413537007, 2733584891633993, 2812411720528947, 2882676970678137, 2903411384421675, 2958418807276103, 3130000929603865, 3175980736717465, 3614311465231655, 3996463578205695, 4103082738409165, 4258621578191541, 4418610303201609, 4647855513194407, 4685348960324559, 4808920381357755, 5183451753845617, 5248837872019479, 5459393081841211, 6169730898746597, 6569116706507233, 6603729845179117, 7155136605307029, 7212160056015967, 7244553210477423, 7384589786348845, 7713430447934781, 8114895595811233, 8209510986022041, 8398715614919241, 8563902159010211, 8691058183717011, 8962445733616225]; const arr2 = [163457591720831, 196860880460605, 668872604533663, 681475781382441, 739991228922867, 1204232377264725, 1402567083052239, 1418358979840983, 1875285439667131, 2112478608256379, 2362707116240501, 2480247716891123, 2815699197032227, 2946539963432449, 2978823594913687, 3298444539285921, 3664268267691413, 4277457216782315, 4316531169004027, 4567307451346087, 4655426574120211, 4696413724870613, 4831259468359653, 5052243723913683, 5076825973761899, 5313627140975321, 5549643481155739, 5763038910068197, 5863617689275713, 6100078677408673, 6182322012227663, 6673442111678693, 6677992076967503, 6765194736438189, 6794436664762403, 7138122320940275, 7407652791154167, 7650254427397051, 8784125927428599, 8794961983529061]; const expected = [64649367165265, 163457591720831, 196860880460605, 274632412695799, 412877423124429, 516230628864647, 538837081813693, 668872604533663, 681475781382441, 739991228922867, 746373629824209, 1204232377264725, 1402567083052239, 1418358979840983, 1692897751449627, 1875285439667131, 2112478608256379, 2270037413537007, 2362707116240501, 2480247716891123, 2733584891633993, 2812411720528947, 2815699197032227, 2882676970678137, 2903411384421675, 2946539963432449, 2958418807276103, 2978823594913687, 3130000929603865, 3175980736717465, 3298444539285921, 3614311465231655, 3664268267691413, 3996463578205695, 4103082738409165, 4258621578191541, 4277457216782315, 4316531169004027, 4418610303201609, 4567307451346087, 4647855513194407, 4655426574120211, 4685348960324559, 4696413724870613, 4808920381357755, 4831259468359653, 5052243723913683, 5076825973761899, 5183451753845617, 5248837872019479, 5313627140975321, 5459393081841211, 5549643481155739, 5763038910068197, 5863617689275713, 6100078677408673, 6169730898746597, 6182322012227663, 6569116706507233, 6603729845179117, 6673442111678693, 6677992076967503, 6765194736438189, 6794436664762403, 7138122320940275, 7155136605307029, 7212160056015967, 7244553210477423, 7384589786348845, 7407652791154167, 7650254427397051, 7713430447934781, 8114895595811233, 8209510986022041, 8398715614919241, 8563902159010211, 8691058183717011, 8784125927428599, 8794961983529061, 8962445733616225]; const actual = mergeArrays(arr1, arr2); assert.deepStrictEqual(actual, expected); }); it("should work with negative numbers", function() { const arr1 = [-4627886, -4519642, -4297468, -3595491, -3205849, -3099984, -2661963, -2191758, -1832781, -1477357, -1471131, -1392509, -455864, 250084, 1071449, 1103428, 1305440, 1425801, 1452987, 1532745, 1820483, 1840962, 2148348, 2527057, 2706849, 2812677, 2835553, 2947423, 3258963, 3343546, 3493747, 3549879, 4084746, 4159368, 4323454, 4500321, 4642668, 4726588, 4913852, 4978575]; const arr2 = [-1436270, -1334241, -694068, -244520, 1285751, 1459606, 1914385, 2306127, 6078989, 6238068, 6361720, 8166625, 8603728, 8767531, 8886489, 9376132, 10396281, 12030028, 15631727, 17886989, 19258356, 19806234, 24055975, 24357484, 26714565, 26764202, 26854242, 27389146, 28432253, 28734874, 31107482, 31394025, 32185014, 32211940, 33730728, 35244675, 35505202, 35540727, 36742659, 38872319]; const expected = [-4627886, -4519642, -4297468, -3595491, -3205849, -3099984, -2661963, -2191758, -1832781, -1477357, -1471131, -1436270, -1392509, -1334241, -694068, -455864, -244520, 250084, 1071449, 1103428, 1285751, 1305440, 1425801, 1452987, 1459606, 1532745, 1820483, 1840962, 1914385, 2148348, 2306127, 2527057, 2706849, 2812677, 2835553, 2947423, 3258963, 3343546, 3493747, 3549879, 4084746, 4159368, 4323454, 4500321, 4642668, 4726588, 4913852, 4978575, 6078989, 6238068, 6361720, 8166625, 8603728, 8767531, 8886489, 9376132, 10396281, 12030028, 15631727, 17886989, 19258356, 19806234, 24055975, 24357484, 26714565, 26764202, 26854242, 27389146, 28432253, 28734874, 31107482, 31394025, 32185014, 32211940, 33730728, 35244675, 35505202, 35540727, 36742659, 38872319]; const actual = mergeArrays(arr1, arr2); assert.deepStrictEqual(actual, expected); }); it("should work with zeros", function() { const arr1 = [-4627886, -4519642, -4297468, -3595491, -3205849, -3099984, -2661963, -2191758, -1832781, -1477357, -1471131, -1392509, -455864, 0, 250084, 1071449, 1103428, 1305440, 1425801, 1452987, 1532745, 1820483, 1840962, 2148348, 2527057, 2706849, 2812677, 2835553, 2947423, 3258963, 3343546, 3493747, 3549879, 4084746, 4159368, 4323454, 4500321, 4642668, 4726588, 4913852, 4978575]; const arr2 = [-1436270, -1334241, -694068, -244520, 0, 1285751, 1459606, 1914385, 2306127, 6078989, 6238068, 6361720, 8166625, 8603728, 8767531, 8886489, 9376132, 10396281, 12030028, 15631727, 17886989, 19258356, 19806234, 24055975, 24357484, 26714565, 26764202, 26854242, 27389146, 28432253, 28734874, 31107482, 31394025, 32185014, 32211940, 33730728, 35244675, 35505202, 35540727, 36742659, 38872319]; const expected = [-4627886, -4519642, -4297468, -3595491, -3205849, -3099984, -2661963, -2191758, -1832781, -1477357, -1471131, -1436270, -1392509, -1334241, -694068, -455864, -244520, 0, 0, 250084, 1071449, 1103428, 1285751, 1305440, 1425801, 1452987, 1459606, 1532745, 1820483, 1840962, 1914385, 2148348, 2306127, 2527057, 2706849, 2812677, 2835553, 2947423, 3258963, 3343546, 3493747, 3549879, 4084746, 4159368, 4323454, 4500321, 4642668, 4726588, 4913852, 4978575, 6078989, 6238068, 6361720, 8166625, 8603728, 8767531, 8886489, 9376132, 10396281, 12030028, 15631727, 17886989, 19258356, 19806234, 24055975, 24357484, 26714565, 26764202, 26854242, 27389146, 28432253, 28734874, 31107482, 31394025, 32185014, 32211940, 33730728, 35244675, 35505202, 35540727, 36742659, 38872319]; const actual = mergeArrays(arr1, arr2); assert.deepStrictEqual(actual, expected); }); });
- // If the failure output for deep equality is truncated, `chai.config.truncateThreshold` can be adjusted.
- const assert = require("assert");
- describe("mergeArray", function() {
- it("should work for 2 empty arrays", function() {
- const arr1 = [];
- const arr2 = [];
- const expected = [];
- const actual = mergeArrays(arr1, arr2);
- assert.deepStrictEqual(actual, expected);
- });
- it("should work with a single empty array", function() {
- const arr1 = [1,3,5,7,9,11,13,15,17,19,200];
- const arr2 = [];
- const expected = [1,3,5,7,9,11,13,15,17,19,200];
- const actual = mergeArrays(arr1, arr2);
- console.log(actual)
- assert.deepStrictEqual(actual, expected);
- });
- it("should work with large numbers", function() {
- const arr1 = [64649367165265, 274632412695799, 412877423124429, 516230628864647, 538837081813693, 746373629824209, 1692897751449627, 2270037413537007, 2733584891633993, 2812411720528947, 2882676970678137, 2903411384421675, 2958418807276103, 3130000929603865, 3175980736717465, 3614311465231655, 3996463578205695, 4103082738409165, 4258621578191541, 4418610303201609, 4647855513194407, 4685348960324559, 4808920381357755, 5183451753845617, 5248837872019479, 5459393081841211, 6169730898746597, 6569116706507233, 6603729845179117, 7155136605307029, 7212160056015967, 7244553210477423, 7384589786348845, 7713430447934781, 8114895595811233, 8209510986022041, 8398715614919241, 8563902159010211, 8691058183717011, 8962445733616225];
- const arr2 = [163457591720831, 196860880460605, 668872604533663, 681475781382441, 739991228922867, 1204232377264725, 1402567083052239, 1418358979840983, 1875285439667131, 2112478608256379, 2362707116240501, 2480247716891123, 2815699197032227, 2946539963432449, 2978823594913687, 3298444539285921, 3664268267691413, 4277457216782315, 4316531169004027, 4567307451346087, 4655426574120211, 4696413724870613, 4831259468359653, 5052243723913683, 5076825973761899, 5313627140975321, 5549643481155739, 5763038910068197, 5863617689275713, 6100078677408673, 6182322012227663, 6673442111678693, 6677992076967503, 6765194736438189, 6794436664762403, 7138122320940275, 7407652791154167, 7650254427397051, 8784125927428599, 8794961983529061];
- const expected = [64649367165265, 163457591720831, 196860880460605, 274632412695799, 412877423124429, 516230628864647, 538837081813693, 668872604533663, 681475781382441, 739991228922867, 746373629824209, 1204232377264725, 1402567083052239, 1418358979840983, 1692897751449627, 1875285439667131, 2112478608256379, 2270037413537007, 2362707116240501, 2480247716891123, 2733584891633993, 2812411720528947, 2815699197032227, 2882676970678137, 2903411384421675, 2946539963432449, 2958418807276103, 2978823594913687, 3130000929603865, 3175980736717465, 3298444539285921, 3614311465231655, 3664268267691413, 3996463578205695, 4103082738409165, 4258621578191541, 4277457216782315, 4316531169004027, 4418610303201609, 4567307451346087, 4647855513194407, 4655426574120211, 4685348960324559, 4696413724870613, 4808920381357755, 4831259468359653, 5052243723913683, 5076825973761899, 5183451753845617, 5248837872019479, 5313627140975321, 5459393081841211, 5549643481155739, 5763038910068197, 5863617689275713, 6100078677408673, 6169730898746597, 6182322012227663, 6569116706507233, 6603729845179117, 6673442111678693, 6677992076967503, 6765194736438189, 6794436664762403, 7138122320940275, 7155136605307029, 7212160056015967, 7244553210477423, 7384589786348845, 7407652791154167, 7650254427397051, 7713430447934781, 8114895595811233, 8209510986022041, 8398715614919241, 8563902159010211, 8691058183717011, 8784125927428599, 8794961983529061, 8962445733616225];
- const actual = mergeArrays(arr1, arr2);
- assert.deepStrictEqual(actual, expected);
- });
- it("should work with negative numbers", function() {
- const arr1 = [-4627886, -4519642, -4297468, -3595491, -3205849, -3099984, -2661963, -2191758, -1832781, -1477357, -1471131, -1392509, -455864, 250084, 1071449, 1103428, 1305440, 1425801, 1452987, 1532745, 1820483, 1840962, 2148348, 2527057, 2706849, 2812677, 2835553, 2947423, 3258963, 3343546, 3493747, 3549879, 4084746, 4159368, 4323454, 4500321, 4642668, 4726588, 4913852, 4978575];
- const arr2 = [-1436270, -1334241, -694068, -244520, 1285751, 1459606, 1914385, 2306127, 6078989, 6238068, 6361720, 8166625, 8603728, 8767531, 8886489, 9376132, 10396281, 12030028, 15631727, 17886989, 19258356, 19806234, 24055975, 24357484, 26714565, 26764202, 26854242, 27389146, 28432253, 28734874, 31107482, 31394025, 32185014, 32211940, 33730728, 35244675, 35505202, 35540727, 36742659, 38872319];
- const expected = [-4627886, -4519642, -4297468, -3595491, -3205849, -3099984, -2661963, -2191758, -1832781, -1477357, -1471131, -1436270, -1392509, -1334241, -694068, -455864, -244520, 250084, 1071449, 1103428, 1285751, 1305440, 1425801, 1452987, 1459606, 1532745, 1820483, 1840962, 1914385, 2148348, 2306127, 2527057, 2706849, 2812677, 2835553, 2947423, 3258963, 3343546, 3493747, 3549879, 4084746, 4159368, 4323454, 4500321, 4642668, 4726588, 4913852, 4978575, 6078989, 6238068, 6361720, 8166625, 8603728, 8767531, 8886489, 9376132, 10396281, 12030028, 15631727, 17886989, 19258356, 19806234, 24055975, 24357484, 26714565, 26764202, 26854242, 27389146, 28432253, 28734874, 31107482, 31394025, 32185014, 32211940, 33730728, 35244675, 35505202, 35540727, 36742659, 38872319];
- const actual = mergeArrays(arr1, arr2);
- assert.deepStrictEqual(actual, expected);
- });
- it("should work with zeros", function() {
- const arr1 = [-4627886, -4519642, -4297468, -3595491, -3205849, -3099984, -2661963, -2191758, -1832781, -1477357, -1471131, -1392509, -455864, 0, 250084, 1071449, 1103428, 1305440, 1425801, 1452987, 1532745, 1820483, 1840962, 2148348, 2527057, 2706849, 2812677, 2835553, 2947423, 3258963, 3343546, 3493747, 3549879, 4084746, 4159368, 4323454, 4500321, 4642668, 4726588, 4913852, 4978575];
- const arr2 = [-1436270, -1334241, -694068, -244520, 0, 1285751, 1459606, 1914385, 2306127, 6078989, 6238068, 6361720, 8166625, 8603728, 8767531, 8886489, 9376132, 10396281, 12030028, 15631727, 17886989, 19258356, 19806234, 24055975, 24357484, 26714565, 26764202, 26854242, 27389146, 28432253, 28734874, 31107482, 31394025, 32185014, 32211940, 33730728, 35244675, 35505202, 35540727, 36742659, 38872319];
- const expected = [-4627886, -4519642, -4297468, -3595491, -3205849, -3099984, -2661963, -2191758, -1832781, -1477357, -1471131, -1436270, -1392509, -1334241, -694068, -455864, -244520, 0, 0, 250084, 1071449, 1103428, 1285751, 1305440, 1425801, 1452987, 1459606, 1532745, 1820483, 1840962, 1914385, 2148348, 2306127, 2527057, 2706849, 2812677, 2835553, 2947423, 3258963, 3343546, 3493747, 3549879, 4084746, 4159368, 4323454, 4500321, 4642668, 4726588, 4913852, 4978575, 6078989, 6238068, 6361720, 8166625, 8603728, 8767531, 8886489, 9376132, 10396281, 12030028, 15631727, 17886989, 19258356, 19806234, 24055975, 24357484, 26714565, 26764202, 26854242, 27389146, 28432253, 28734874, 31107482, 31394025, 32185014, 32211940, 33730728, 35244675, 35505202, 35540727, 36742659, 38872319];
- const actual = mergeArrays(arr1, arr2);
- assert.deepStrictEqual(actual, expected);
- });
- });
class UniqueInOrderIterator: def __init__(self, iterable): self.__iterable = iterable self.__currentPosition = 0 self.__lastElement = None def __iter__(self): return self def __next__(self): self.__pointToNextValidElement() result = self.__pointedElement() self.__pointToNextElement() return result def __pointToNextValidElement(self): while (self.__currentPosition < len(self.__iterable) and self.__iterable[self.__currentPosition] == self.__lastElement): self.__pointToNextElement() def __pointedElement(self): return self.__iterable[self.__currentPosition] def __pointToNextElement(self): self.__lastElement = self.__pointedElement() self.__currentPosition += 1 self.__stopIfEndReached() def __stopIfEndReached(self): if self.__currentPosition >= len(self.__iterable): raise StopIteration def unique_in_order(iterable): unique = [] uniqueInOrderIterator = UniqueInOrderIterator(iterable) for element in uniqueInOrderIterator: unique.append(element) return unique
- class UniqueInOrderIterator:
- def __init__(self, iterable):
- self.__iterable = iterable
- self.__currentPosition = 0
- self.__lastElement = None
- def __iter__(self):
- return self
- def __next__(self):
- self.__pointToNextValidElement()
- result = self.__pointedElement()
- self.__pointToNextElement()
- return result
- def __pointToNextValidElement(self):
- while (self.__currentPosition < len(self.__iterable)
- and self.__iterable[self.__currentPosition] == self.__lastElement):
- self.__pointToNextElement()
- def __pointedElement(self):
- return self.__iterable[self.__currentPosition]
- def __pointToNextElement(self):
- self.__lastElement = self.__pointedElement()
- self.__currentPosition += 1
- self.__stopIfEndReached()
- def __stopIfEndReached(self):
- if self.__currentPosition >= len(self.__iterable):
- raise StopIteration
- def unique_in_order(iterable):
- unique = []
- uniqueInOrderIterator = UniqueInOrderIterator(iterable)
for i in range(len(iterable)):if (i == 0):unique.append(iterable[i])elif iterable[i] != unique[-1]:unique.append(iterable[i])- for element in uniqueInOrderIterator:
- unique.append(element)
- return unique
Here's some of my expirements
var canvas = require('canvas') const { assert } = require('chai') describe("Fixed tests", () => { function showMaurerRose(locations, length) { var draw = new canvas(length, length) var ctx = draw.getContext('2d') ctx.fillStyle = "rgb(10, 10, 10)" ctx.fillRect(0, 0, length, length) ctx.beginPath() ctx.strokeStyle = '#fff' ctx.moveTo(locations[0][0], locations[0][1]) for (var loc of locations) ctx.lineTo(loc[0], loc[1]) ctx.stroke() console.log('<img src="' + draw.toDataURL() + '"/>') } function solution(n, d, length) { length /= 2 var locations = [] for (var i = 0; i <= 360; i++) { var k = i * d * Math.PI / 180 var r = Math.sin(n * k) * length var a = r * Math.cos(k) + length var b = r * Math.sin(k) + length locations.push([Math.round(a), Math.round(b)]) } return locations } var roses = [ [1, 50], [2, 49], [3, 48], [4, 47], [5, 46], [6, 45], [7, 44], [35, 6], [34, 7], [14, 2], [20, 50], [27, 8], [21, 14], [50, 32] ] roses.forEach(rose => { var length = 200 var expected = solution(rose[0], rose[1], length) var actual = maurerRose(rose[0], rose[1], length) console.log(`n${rose[0]} d${rose[1]}`) showMaurerRose(actual, length) assert.strictEqual(actual.slice(0, 5)+``, expected.slice(0, 5)+``) }); });
- var canvas = require('canvas')
- const { assert } = require('chai')
- describe("Fixed tests", () => {
- function showMaurerRose(locations, length) {
- var draw = new canvas(length, length)
- var ctx = draw.getContext('2d')
- ctx.fillStyle = "rgb(10, 10, 10)"
- ctx.fillRect(0, 0, length, length)
- ctx.beginPath()
- ctx.strokeStyle = '#fff'
- ctx.moveTo(locations[0][0], locations[0][1])
- for (var loc of locations)
- ctx.lineTo(loc[0], loc[1])
- ctx.stroke()
- console.log('<img src="' + draw.toDataURL() + '"/>')
- }
- function solution(n, d, length) {
- length /= 2
- var locations = []
- for (var i = 0; i <= 360; i++) {
- var k = i * d * Math.PI / 180
- var r = Math.sin(n * k) * length
- var a = r * Math.cos(k) + length
- var b = r * Math.sin(k) + length
- locations.push([Math.round(a), Math.round(b)])
- }
- return locations
- }
- var roses = [
[4, 74], [18, 22], [5, 82], [4, 42], [18, 9], [9, 82], [6, 71],[8, 56], [3, 42], [14, 5], [2, 39], [3, 65], [9, 23], [11, 101],[8, 51], [3, 87], [2, 51], [18, 77], [8, 12], [15, 14], [18, 19],[4, 39], [15, 62], [8, 46], [7, 42], [7, 59], [2, 95], [33, 91]- [1, 50], [2, 49], [3, 48], [4, 47], [5, 46], [6, 45], [7, 44],
- [35, 6], [34, 7], [14, 2], [20, 50], [27, 8], [21, 14], [50, 32]
- ]
- roses.forEach(rose => {
- var length = 200
- var expected = solution(rose[0], rose[1], length)
- var actual = maurerRose(rose[0], rose[1], length)
- console.log(`n${rose[0]} d${rose[1]}`)
- showMaurerRose(actual, length)
- assert.strictEqual(actual.slice(0, 5)+``, expected.slice(0, 5)+``)
- });
- });
public class Kumite{ public static String switchout(String in, String replace, String instead){ return in.replaceAll(replace, instead);}}
switchout = str.replace- public class Kumite{
- public static String switchout(String in, String replace, String instead){
- return in.replaceAll(replace, instead);}}
import org.junit.Test; import static org.junit.Assert.assertEquals; import org.junit.runners.JUnit4; public class Switchout { @Test public void smartToDumb() { assertEquals("I am dumb", Kumite.switchout("I am smart", "smart", "dumb")); } @Test public void yesToNo(){ assertEquals("I am smart? No!", Kumite.switchout("I am smart? Yes!", "Yes", "No")); } }
test.assert_equals(switchout("I am smart", "smart", "dumb"), "I am dumb")test.assert_equals(switchout("Cats are fun", "fun", "evil"), "Cats are evil")- import org.junit.Test;
- import static org.junit.Assert.assertEquals;
- import org.junit.runners.JUnit4;
- public class Switchout {
- @Test
- public void smartToDumb() {
- assertEquals("I am dumb", Kumite.switchout("I am smart", "smart", "dumb"));
- }
- @Test
- public void yesToNo(){
- assertEquals("I am smart? No!", Kumite.switchout("I am smart? Yes!", "Yes", "No"));
- }
- }
def interleave(*args): r = [] for i in range(max(len(x) for x in args)): for x in args: if i < len(x): r.append(x[i]) else: break return r
def interleave(*argv):lists = len(argv)if 1 == lists:return argv[0]else:o = [x for t in zip(*argv) for x in t]for i in reversed(range(0, lists - 1)):l = len(argv[i + 1])lists = []for _list in argv[:i+1]:lists.append(_list[l:])o += [x for t in zip(*lists) for x in t]return o- def interleave(*args):
- r = []
- for i in range(max(len(x) for x in args)):
- for x in args:
- if i < len(x):
- r.append(x[i])
- else:
- break
- return r
test.assert_equals(interleave([]), []) test.assert_equals(interleave([1,2]), [1,2]) test.assert_equals(interleave([1,2,3], ['a','b','c']), [1,'a',2,'b',3,'c']) test.assert_equals(interleave([1, 2, 3], [4, 5], [6, 7, 8]), [1, 4, 6, 2, 5, 7, 3]) test.assert_equals(interleave([1], [4, 5], [6, 7, 8]), [1, 4, 6]) test.assert_equals(interleave(list(range(1, 11, 3)), list(range(2, 11, 3)), list(range(3, 11, 3))), list(range(1, 11)))
- test.assert_equals(interleave([]), [])
- test.assert_equals(interleave([1,2]), [1,2])
- test.assert_equals(interleave([1,2,3], ['a','b','c']), [1,'a',2,'b',3,'c'])
- test.assert_equals(interleave([1, 2, 3], [4, 5], [6, 7, 8]), [1, 4, 6, 2, 5, 7, 3])
- test.assert_equals(interleave([1], [4, 5], [6, 7, 8]), [1, 4, 6])
- test.assert_equals(interleave(list(range(1, 11, 3)), list(range(2, 11, 3)), list(range(3, 11, 3))), list(range(1, 11)))
const returnhundred = () => +(~(~[]<<!![])<<!![]<<!![]).toString(~(~[]<<!![])<<!![]);
const returnhundred = () => process.version.slice(1).split('.')[0] ** 2;// WARNING: Only works in Node 10. Node 8 will give 80 and Node 6 will give 60- const returnhundred = () => +(~(~[]<<!![])<<!![]<<!![]).toString(~(~[]<<!![])<<!![]);
and simplified more