// some other ways isPangram=s=>[...'abcdefghijklmnopqrstuvwxyz'].every(e=>s.toLowerCase().includes(e)) isPangram=s=>[...'abcdefghijklmnopqrstuvwxyz'].every(e=>RegExp(e,'i').test(s)) isPangram=s=>[...new Set(s.toLowerCase().match(/[a-z]/g))].length>25 isPangram=s=>new Set(s.toLowerCase().match(/[a-z]/g)).size>25
let isPangram =str=>'abcdefghijklmnopqrstuvwxyz'.split``.every(v => ~str.toLowerCase().indexOf(v))- // some other ways
- isPangram=s=>[...'abcdefghijklmnopqrstuvwxyz'].every(e=>s.toLowerCase().includes(e))
- isPangram=s=>[...'abcdefghijklmnopqrstuvwxyz'].every(e=>RegExp(e,'i').test(s))
- isPangram=s=>[...new Set(s.toLowerCase().match(/[a-z]/g))].length>25
- isPangram=s=>new Set(s.toLowerCase().match(/[a-z]/g)).size>25
describe("Solution", function() { it("should passed all test", function() { Test.assertEquals(isPangram('Quick zephyrs blow, vexing daft Jim'),true); Test.assertEquals(isPangram('Sphinx of black quartz, judge my vow'),true); Test.assertEquals(isPangram('Two driven jocks help fax my big quiz'),true); Test.assertEquals(isPangram(' Five quacking zephyrs jolt my wax bed'),true); Test.assertEquals(isPangram('A mad boxer shot a quick, gloved jab to the jaw of his dizzy opponent'),true); Test.assertEquals(isPangram('Quick zephyrs blow, vexing daft '),false); }); });
// 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 passed all test", function() {
- Test.assertEquals(isPangram('Quick zephyrs blow, vexing daft Jim'),true);
- Test.assertEquals(isPangram('Sphinx of black quartz, judge my vow'),true);
Test.assertEquals(isPangram('Two driven jocks help fax my big quiz'),true);Test.assertEquals(isPangram(' Five quacking zephyrs jolt my wax bed'),true);//A mad boxer shot a quick, gloved jab to the jaw of his dizzy opponentTest.assertEquals(isPangram('A mad boxer shot a quick, gloved jab to the jaw of his dizzy opponent'),true);Test.assertEquals(isPangram('Quick zephyrs blow, vexing daft '),false);// assert.strictEqual(1 + 1, 2);- Test.assertEquals(isPangram('Two driven jocks help fax my big quiz'),true);
- Test.assertEquals(isPangram(' Five quacking zephyrs jolt my wax bed'),true);
- Test.assertEquals(isPangram('A mad boxer shot a quick, gloved jab to the jaw of his dizzy opponent'),true);
- Test.assertEquals(isPangram('Quick zephyrs blow, vexing daft '),false);
- });
});- });
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);
- });
- });
# 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'])
Just seeing if I can get the canvas element to work.
The best way to see the canvasses is to hit Fork, then Run, then look at the test logs.
More information about these images:
https://en.wikipedia.org/wiki/Maurer_rose
function maurerRose(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 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]
]
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)+``)
});
});
Same solution. Just added more tests.
describe("Solution", function() { it("should test for something", function() { var tree1 = {id:2, poisoned:false, left:{id:17, poisoned:false, left: {id:4, poisoned:false, left:{id:7, poisoned:false}, right:{id:13, poisoned:true}}}, right:{id:62, poisoned:false, left:{id:11, poisoned:false}} } var tree2 = {id:0, poisoned:false, left:{id:15, poisoned:false, left: {id:4, poisoned:false, left:{id:7, poisoned:false}, right:{id:13, poisoned:false}}}, right:{id:6, poisoned:false, left:{id:11, poisoned:false}} } // no branch tests Test.assertEquals(findPoisoned({id:6, poisoned:true}), 6); Test.assertEquals(findPoisoned({id:7, poisoned:false}), -1); // one branch tests Test.assertEquals(findPoisoned({id:5, poisoned:false, left:{id:4, poisoned:true} }), 4); Test.assertEquals(findPoisoned({id:3, poisoned:false, right:{id:1, poisoned:true} }), 1); Test.assertEquals(findPoisoned({id:1, poisoned:false, right:{id:9, poisoned:false} }), -1); // two branch tests Test.assertEquals(findPoisoned({id:8, poisoned:false, left:{id:4, poisoned:false}, right:{id:7, poisoned:true} }), 7); Test.assertEquals(findPoisoned({id:5, poisoned:false, left:{id:3, poisoned:true}, right:{id:4, poisoned:false} }), 3); Test.assertEquals(findPoisoned({id:5, poisoned:false, right:{id:4, poisoned:false}, left:{id:0, poisoned:true}, }), 0); Test.assertEquals(findPoisoned({id:7, poisoned:false, left:{id:3, poisoned:false}, right:{id:4, poisoned:false} }), -1); // multiple branch tests Test.assertEquals(findPoisoned(tree1), 13); Test.assertEquals(findPoisoned(tree2), -1); // one long branch test Test.assertEquals(findPoisoned({id:4, poisoned:false, left:{id:8, poisoned:false, left:{id:15, poisoned:false, left:{id:16, poisoned:false, left:{id:23, poisoned:false, left:{id:42, poisoned:true}}}}}}), 42); Test.assertEquals(findPoisoned({id:4, poisoned:false, left:{id:8, poisoned:false, left:{id:15, poisoned:false, left:{id:16, poisoned:false, left:{id:23, poisoned:false, left:{id:42, poisoned:false}}}}}}), -1); }); });
// 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(findPoisoned({id:2, poisoned:true}), 2);Test.assertEquals(findPoisoned({id:2, poisoned:false}), -1);Test.assertEquals(findPoisoned({id:2, poisoned:false, left:{id:4 , poisoned:true} }), 4);Test.assertEquals(findPoisoned({id:2, poisoned:false, right:{id:4 , poisoned:true} }), 4);- var tree1 = {id:2, poisoned:false, left:{id:17, poisoned:false, left: {id:4, poisoned:false, left:{id:7, poisoned:false}, right:{id:13, poisoned:true}}}, right:{id:62, poisoned:false, left:{id:11, poisoned:false}} }
- var tree2 = {id:0, poisoned:false, left:{id:15, poisoned:false, left: {id:4, poisoned:false, left:{id:7, poisoned:false}, right:{id:13, poisoned:false}}}, right:{id:6, poisoned:false, left:{id:11, poisoned:false}} }
- // no branch tests
- Test.assertEquals(findPoisoned({id:6, poisoned:true}), 6);
- Test.assertEquals(findPoisoned({id:7, poisoned:false}), -1);
- // one branch tests
- Test.assertEquals(findPoisoned({id:5, poisoned:false, left:{id:4, poisoned:true} }), 4);
- Test.assertEquals(findPoisoned({id:3, poisoned:false, right:{id:1, poisoned:true} }), 1);
- Test.assertEquals(findPoisoned({id:1, poisoned:false, right:{id:9, poisoned:false} }), -1);
- // two branch tests
- Test.assertEquals(findPoisoned({id:8, poisoned:false, left:{id:4, poisoned:false}, right:{id:7, poisoned:true} }), 7);
- Test.assertEquals(findPoisoned({id:5, poisoned:false, left:{id:3, poisoned:true}, right:{id:4, poisoned:false} }), 3);
- Test.assertEquals(findPoisoned({id:5, poisoned:false, right:{id:4, poisoned:false}, left:{id:0, poisoned:true}, }), 0);
- Test.assertEquals(findPoisoned({id:7, poisoned:false, left:{id:3, poisoned:false}, right:{id:4, poisoned:false} }), -1);
- // multiple branch tests
- Test.assertEquals(findPoisoned(tree1), 13);
- Test.assertEquals(findPoisoned(tree2), -1);
- // one long branch test
- Test.assertEquals(findPoisoned({id:4, poisoned:false, left:{id:8, poisoned:false, left:{id:15, poisoned:false, left:{id:16, poisoned:false, left:{id:23, poisoned:false, left:{id:42, poisoned:true}}}}}}), 42);
- Test.assertEquals(findPoisoned({id:4, poisoned:false, left:{id:8, poisoned:false, left:{id:15, poisoned:false, left:{id:16, poisoned:false, left:{id:23, poisoned:false, left:{id:42, poisoned:false}}}}}}), -1);
- });
- });
yeeted it
yeet_words=t=>t.replace(/\b\w{4,}\b/g,x=>[...'y'+'e'.repeat(x.length-2)+'t'].map((e,i)=>x[i]<'a'?e.toUpperCase():e).join``)
yeet_words=t=>t.replace(/\b\w{4,}\b/g,x=>(x<'a'?'Y':'y')+'e'.repeat(x.length-2)+'t')- yeet_words=t=>t.replace(/\b\w{4,}\b/g,x=>[...'y'+'e'.repeat(x.length-2)+'t'].map((e,i)=>x[i]<'a'?e.toUpperCase():e).join``)
describe('test', () => { Test.assertEquals(yeet_words("I like to yeet long words like facetrackingdrone!"), "I yeet to yeet yeet yeeet yeet yeeeeeeeeeeeeeeet!") Test.assertEquals(yeet_words("Yeet yeet yeet yeet yeet. Yeet yeet yeet yeet."), "Yeet yeet yeet yeet yeet. Yeet yeet yeet yeet.") Test.assertEquals(yeet_words("I'm about to yeet, all over this sentence. Hurray!"), "I'm yeeet to yeet, all yeet yeet yeeeeeet. Yeeeet!") Test.assertEquals(yeet_words("yOOOOoooOO!"), "yEEEEeeeET!") })
- describe('test', () => {
- Test.assertEquals(yeet_words("I like to yeet long words like facetrackingdrone!"), "I yeet to yeet yeet yeeet yeet yeeeeeeeeeeeeeeet!")
- Test.assertEquals(yeet_words("Yeet yeet yeet yeet yeet. Yeet yeet yeet yeet."), "Yeet yeet yeet yeet yeet. Yeet yeet yeet yeet.")
- Test.assertEquals(yeet_words("I'm about to yeet, all over this sentence. Hurray!"), "I'm yeeet to yeet, all yeet yeet yeeeeeet. Yeeeet!")
- Test.assertEquals(yeet_words("yOOOOoooOO!"), "yEEEEeeeET!")
- })
highAndLow=a=>Math.max(...a=a.split` `)+` `+Math.min(...a)
public class Kumite {public static String highAndLow(String numbers) {String[] integerStrings = numbers.split(" ");int maxValue = Integer.parseInt(integerStrings[0]);int minValue = Integer.parseInt(integerStrings[0]);for (int i = 1; i < integerStrings.length; i++){int number = Integer.parseInt(integerStrings[i]);if(number > maxValue){maxValue = number;}if(number < minValue){minValue = number;}}return Integer.toString(maxValue) + " " + Integer.toString(minValue);}}- highAndLow=a=>Math.max(...a=a.split` `)+` `+Math.min(...a)
describe('tests', () => { Test.assertEquals(highAndLow("1 4 2 6 1 6 1 5 2 8 9"), "9 1") Test.assertEquals(highAndLow("1 4 2 6 -10 6 1 5 2 8 9"), "9 -10") Test.assertEquals(highAndLow("5"), "5 5") Test.assertEquals(highAndLow("-13"), "-13 -13") Test.assertEquals(highAndLow("-42 -15 -16 -23 -8 -4"), "-4 -42") Test.assertEquals(highAndLow("7 2369"), "2369 7") Test.assertEquals(highAndLow("138 2945 78 0 18752 924"), "18752 0") Test.assertEquals(highAndLow("-289 0 289"), "289 -289") })
import org.junit.Test;import static org.junit.Assert.assertEquals;import org.junit.runners.JUnit4;// TODO: Replace examples and use TDD development by writing your own testspublic class SolutionTest {@Testpublic void testSomething() {assertEquals("9 1", Kumite.highAndLow("1 4 2 6 1 6 1 5 2 8 9"));assertEquals("9 -10", Kumite.highAndLow("1 4 2 6 -10 6 1 5 2 8 9"));}}- describe('tests', () => {
- Test.assertEquals(highAndLow("1 4 2 6 1 6 1 5 2 8 9"), "9 1")
- Test.assertEquals(highAndLow("1 4 2 6 -10 6 1 5 2 8 9"), "9 -10")
- Test.assertEquals(highAndLow("5"), "5 5")
- Test.assertEquals(highAndLow("-13"), "-13 -13")
- Test.assertEquals(highAndLow("-42 -15 -16 -23 -8 -4"), "-4 -42")
- Test.assertEquals(highAndLow("7 2369"), "2369 7")
- Test.assertEquals(highAndLow("138 2945 78 0 18752 924"), "18752 0")
- Test.assertEquals(highAndLow("-289 0 289"), "289 -289")
- })
yeet_words=t=>t.replace(/\b\w{4,}\b/g,x=>(x<'a'?'Y':'y')+'e'.repeat(x.length-2)+'t')
def yeet_words(sentence)yeeted = []for word in sentence.split(' ') donew_word = nill = word.match(/\w+/)[0].lengthif l > 3yeet = 'y' + 'e' * (l - 2) + 't'new_word = word.gsub(/\w+/, yeet)endnew_word = new_word.nil? ? word : new_wordyeeted << new_wordendyeeted.join(' ').capitalize()end- yeet_words=t=>t.replace(/\b\w{4,}\b/g,x=>(x<'a'?'Y':'y')+'e'.repeat(x.length-2)+'t')
describe('test', () => { Test.assertEquals(yeet_words("I like to yeet long words like facetrackingdrone!"), "I yeet to yeet yeet yeeet yeet yeeeeeeeeeeeeeeet!") Test.assertEquals(yeet_words("Yeet yeet yeet yeet yeet. Yeet yeet yeet yeet."), "Yeet yeet yeet yeet yeet. Yeet yeet yeet yeet.") Test.assertEquals(yeet_words("I'm about to yeet, all over this sentence. Hurray!"), "I'm yeeet to yeet, all yeet yeet yeeeeeet. Yeeeet!") })
describe "yeet_words" doit "should yeet the sentence" doTest.assert_equals(yeet_words("I like to yeet long words like facetrackingdrone!"), "I yeet to yeet yeet yeeet yeet yeeeeeeeeeeeeeeet!", "NOT YEETED")Test.assert_equals(yeet_words("Yeet yeet yeet yeet yeet yeet yeet yeet yeet."), "Yeet yeet yeet yeet yeet yeet yeet yeet yeet.", "NOT YEETED")Test.assert_equals(yeet_words("I'm about to yeet all over this sentence."), "I'm yeeet to yeet all yeet yeet yeeeeeet.", "NOT YEETED")endend- describe('test', () => {
- Test.assertEquals(yeet_words("I like to yeet long words like facetrackingdrone!"), "I yeet to yeet yeet yeeet yeet yeeeeeeeeeeeeeeet!")
- Test.assertEquals(yeet_words("Yeet yeet yeet yeet yeet. Yeet yeet yeet yeet."), "Yeet yeet yeet yeet yeet. Yeet yeet yeet yeet.")
- Test.assertEquals(yeet_words("I'm about to yeet, all over this sentence. Hurray!"), "I'm yeeet to yeet, all yeet yeet yeeeeeet. Yeeeet!")
- })
// i assume this is an allowed use of "/" :) dividedByThree=n=>/^-?0*(0*1(01*0)*1)*0*$/.test(n.toString(2))
def dividedByThree(number):if number == 0:return Falsereturn abs(number) % 3 == 0- // i assume this is an allowed use of "/" :)
- dividedByThree=n=>/^-?0*(0*1(01*0)*1)*0*$/.test(n.toString(2))
Test.assertEquals(dividedByThree(3),true) Test.assertEquals(dividedByThree(12),true) Test.assertEquals(dividedByThree(13),false) Test.assertEquals(dividedByThree(0),true) Test.assertEquals(dividedByThree(-12),true)
Test.assert_equals(dividedByThree(3),True)Test.assert_equals(dividedByThree(12),True)Test.assert_equals(dividedByThree(13),False)Test.assert_equals(dividedByThree(0),False)Test.assert_equals(dividedByThree(-12),True)- Test.assertEquals(dividedByThree(3),true)
- Test.assertEquals(dividedByThree(12),true)
- Test.assertEquals(dividedByThree(13),false)
- Test.assertEquals(dividedByThree(0),true)
- Test.assertEquals(dividedByThree(-12),true)
basicOp=(a,c,t)=>[...`-+*/`].includes(a)?eval(c+a+t):`Invalid Operation`
function basicOp(operation, value1, value2) {switch (operation) {case '+':return value1 + value2;case '-':return value1 - value2;case '*':return value1 * value2;case '/':return value1 / value2;default:return 0;//Suppose we're adding 1 and -1.}}- basicOp=(a,c,t)=>[...`-+*/`].includes(a)?eval(c+a+t):`Invalid Operation`
Test.assertEquals(basicOp("-", 2, 1), 1) Test.assertEquals(basicOp("+", 3, 3), 6) Test.assertEquals(basicOp("/", 8, 2), 4) Test.assertEquals(basicOp("*", 4, 5), 20) Test.assertEquals(basicOp("-", -12, 9), -21) Test.assertEquals(basicOp("@", 6, 3), "Invalid Operation") Test.assertEquals(basicOp("+", 23, 17), 40) Test.assertEquals(basicOp("/", 111, 37), 3) Test.assertEquals(basicOp("-", 230, 133), 97) Test.assertEquals(basicOp("*", 42, 63), 2646)
// 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);});});- Test.assertEquals(basicOp("-", 2, 1), 1)
- Test.assertEquals(basicOp("+", 3, 3), 6)
- Test.assertEquals(basicOp("/", 8, 2), 4)
- Test.assertEquals(basicOp("*", 4, 5), 20)
- Test.assertEquals(basicOp("-", -12, 9), -21)
- Test.assertEquals(basicOp("@", 6, 3), "Invalid Operation")
- Test.assertEquals(basicOp("+", 23, 17), 40)
- Test.assertEquals(basicOp("/", 111, 37), 3)
- Test.assertEquals(basicOp("-", 230, 133), 97)
- Test.assertEquals(basicOp("*", 42, 63), 2646)
I have chosen to implement the best sorting algorithm, which is bogosort. I use bogosort in all of my production code and I've collected quotes from my clients:
"It has performance unlike any other algorithm."
"I've never seen a sorting algorithm do that before."
"After I input a million records and saw the code running, the tears just streamed down my face."
"I tried bogosort and then several weeks later I was recommending it to all my competitors."
function isSorted(array) { return array.every((e, i) => !i || array[i] >= array[i-1]) } function shuffle(array) { for (var a = 0; a < array.length; a++) { var b = ~~(Math.random() * array.length); [array[a], array[b]] = [array[b], array[a]] } } function bogoSort(array) { while (!isSorted(array)) shuffle(array); return array; }
function sortWithoutSort(array) {for (let i = 0; i < array.length; i++) {if (i < array.length - 1) {if (array[i] > array[i+1]) {var sortVal = array.splice(i,1)[0];array.splice(i+1, 0, sortVal);sortWithoutSort(array);}}}- function isSorted(array) {
- return array.every((e, i) => !i || array[i] >= array[i-1])
- }
- function shuffle(array) {
- for (var a = 0; a < array.length; a++) {
- var b = ~~(Math.random() * array.length);
- [array[a], array[b]] = [array[b], array[a]]
- }
- }
- function bogoSort(array) {
- while (!isSorted(array))
- shuffle(array);
- return array;
- }
Test.describe("Solution", function() { Test.it("should sort fixed arrays in ascending order", function() { Test.assertSimilar(bogoSort([]),[]); Test.assertSimilar(bogoSort([1]),[1]); Test.assertSimilar(bogoSort([2,4,3,1]),[1,2,3,4]); Test.assertSimilar(bogoSort([2,4,3,1,10,5,6,9,8,7]),[1,2,3,4,5,6,7,8,9,10]); Test.assertSimilar(bogoSort([2,2,2,2]),[2,2,2,2]); Test.assertSimilar(bogoSort([-1,-2,-3,-4]),[-4,-3,-2,-1]); Test.assertSimilar(bogoSort([-1,2,-3,4]),[-3,-1,2,4]); Test.assertSimilar(bogoSort([16,4,23,15,42,8]),[4,8,15,16,23,42]); }); });
- Test.describe("Solution", function() {
- Test.it("should sort fixed arrays in ascending order", function() {
Test.assertSimilar(sortWithoutSort([]),[]);Test.assertSimilar(sortWithoutSort([1]),[1]);Test.assertSimilar(sortWithoutSort([2,4,3,1]),[1,2,3,4]);Test.assertSimilar(sortWithoutSort([2,4,3,1,10,5,6,9,8,7]),[1,2,3,4,5,6,7,8,9,10]);Test.assertSimilar(sortWithoutSort([2,2,2,2]),[2,2,2,2]);Test.assertSimilar(sortWithoutSort([-1,-2,-3,-4]),[-4,-3,-2,-1]);Test.assertSimilar(sortWithoutSort([-1,2,-3,4]),[-3,-1,2,4]);});});Test.describe("Solution", function() {Test.it("should sort random arrays in ascending order", function() {function sort(array) {for (let i = 0; i < array.length; i++) {if (i < array.length - 1) {if (array[i] > array[i+1]) {var sortVal = array.splice(i,1)[0];array.splice(i+1, 0, sortVal);sort(array);}}}return array;}for (let i = 0; i < 25; i++) {let randLength = Math.random(25) * 100 + 1;let array = [];let min = Math.ceil(-100);let max = Math.floor(100);for (let j = 0; j < randLength; j++) {let randVal = Math.floor(Math.random() * (max - min + 1)) + min;array.push(randVal)}Test.assertSimilar(sortWithoutSort(array), sort(array));}- Test.assertSimilar(bogoSort([]),[]);
- Test.assertSimilar(bogoSort([1]),[1]);
- Test.assertSimilar(bogoSort([2,4,3,1]),[1,2,3,4]);
- Test.assertSimilar(bogoSort([2,4,3,1,10,5,6,9,8,7]),[1,2,3,4,5,6,7,8,9,10]);
- Test.assertSimilar(bogoSort([2,2,2,2]),[2,2,2,2]);
- Test.assertSimilar(bogoSort([-1,-2,-3,-4]),[-4,-3,-2,-1]);
- Test.assertSimilar(bogoSort([-1,2,-3,4]),[-3,-1,2,4]);
- Test.assertSimilar(bogoSort([16,4,23,15,42,8]),[4,8,15,16,23,42]);
- });
- });
function invert(str) { var combine = str.repeat(str.length) var n = combine.length var answer = '' while (--n >= 0) { answer += combine[n] n -= str.length } return answer }
const invert = str => str.replace(/./g, (_,o,s) => s.charAt(s.length-1-o));- function invert(str) {
- var combine = str.repeat(str.length)
- var n = combine.length
- var answer = ''
- while (--n >= 0) {
- answer += combine[n]
- n -= str.length
- }
- return answer
- }
const seed = Array.from({length:1+~~(Math.random()*10)}, (rnd,char) => (rnd=Math.random(), char=String.fromCharCode(Math.round(rnd*25)+97), rnd > 0.8 ? char.toUpperCase() : char)), str = seed.join(''), strInv = seed.reverse().join(''); Test.assertEquals(invert(str),strInv);
const seed = Array.from({length:10}, (rnd,char) => (rnd=Math.random(), char=String.fromCharCode(Math.round(rnd*25)+97), rnd > 0.8 ? char.toUpperCase() : char)),- const seed = Array.from({length:1+~~(Math.random()*10)}, (rnd,char) => (rnd=Math.random(), char=String.fromCharCode(Math.round(rnd*25)+97), rnd > 0.8 ? char.toUpperCase() : char)),
- str = seed.join(''),
- strInv = seed.reverse().join('');
- Test.assertEquals(invert(str),strInv);
This is the same as the reference solution, but has a range of tests, so anyone can use this to check the speed of their solution. In the comments below I have compared the speed of the submitted solutions.
function makeRandomData(len) { var data = []; var tracker = 0; for (var a = 0; a < len; a++) { tracker += ~~(1 + (Math.random() * 10)); data.push(Math.random() > 0.5 ? tracker : -tracker); } data = Test.randomize(data); var answer = data[~~(Math.random() * data.length)]; data.splice(~~(Math.random() * (data.length + 1)), 0, -answer); return [data, Math.abs(answer)]; } var dataSets = []; describe("Solution", function() { it("this is where we make the data", function() { for (var a = 5; a <= 50000; a *= 10) { for (var b = 0; b < 10; b++) { var data = makeRandomData(a); dataSets.push(data); } } Test.assertSimilar(1, 1); }); it("this is where we run the user code", function() { for (var dataSet of dataSets) { var user = pairs(dataSet[0]).sort(); Test.assertSimilar(user, [-dataSet[1], dataSet[1]]) } }); });
- function makeRandomData(len) {
- var data = [];
- var tracker = 0;
- for (var a = 0; a < len; a++) {
- tracker += ~~(1 + (Math.random() * 10));
- data.push(Math.random() > 0.5 ? tracker : -tracker);
- }
- data = Test.randomize(data);
- var answer = data[~~(Math.random() * data.length)];
- data.splice(~~(Math.random() * (data.length + 1)), 0, -answer);
- return [data, Math.abs(answer)];
- }
- var dataSets = [];
- describe("Solution", function() {
it("should return right pair", function() {Test.assertSimilar(pairs([1, 3, 6, -2, 4, -6]), [-6,6])Test.assertSimilar(pairs([3, 6, 8, -2, 4, 5, -1, -8]), [-8, 8])- it("this is where we make the data", function() {
- for (var a = 5; a <= 50000; a *= 10) {
- for (var b = 0; b < 10; b++) {
- var data = makeRandomData(a);
- dataSets.push(data);
- }
- }
- Test.assertSimilar(1, 1);
- });
- it("this is where we run the user code", function() {
- for (var dataSet of dataSets) {
- var user = pairs(dataSet[0]).sort();
- Test.assertSimilar(user, [-dataSet[1], dataSet[1]])
- }
- });
- });