sortDisjoint
should be a function.
testString: assert(typeof sortDisjoint == 'function', 'sortDisjoint
should be a function.');
- - text: sortDisjoint([7, 6, 5, 4, 3, 2, 1, 0], [6, 1, 7])
should return a array.
- testString: assert(Array.isArray(sortDisjoint([7, 6, 5, 4, 3, 2, 1, 0], [6, 1, 7])), 'sortDisjoint([7, 6, 5, 4, 3, 2, 1, 0], [6, 1, 7])
should return a array.');
+ - text: sortDisjoint([7, 6, 5, 4, 3, 2, 1, 0], [6, 1, 7])
should return an array.
+ testString: assert(Array.isArray(sortDisjoint([7, 6, 5, 4, 3, 2, 1, 0], [6, 1, 7])), 'sortDisjoint([7, 6, 5, 4, 3, 2, 1, 0], [6, 1, 7])
should return an array.');
- text: sortDisjoint([7, 6, 5, 4, 3, 2, 1, 0], [6, 1, 7])
should return [7, 0, 5, 4, 3, 2, 1, 6]
.
testString: assert.deepEqual(sortDisjoint([7, 6, 5, 4, 3, 2, 1, 0], [6, 1, 7]), [7, 0, 5, 4, 3, 2, 1, 6], 'sortDisjoint([7, 6, 5, 4, 3, 2, 1, 0], [6, 1, 7])
should return [7, 0, 5, 4, 3, 2, 1, 6]
.');
- text: sortDisjoint([7, 6, 5, 4, 3, 2, 1, 0], [1, 2, 5, 6])
should return [7, 1, 2, 4, 3, 5, 6, 0]
.
diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/sort-using-a-custom-comparator.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/sort-using-a-custom-comparator.md
index 07e086a561..54251139db 100644
--- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/sort-using-a-custom-comparator.md
+++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/sort-using-a-custom-comparator.md
@@ -13,6 +13,7 @@ Write a function to sort an array (or list) of strings in order of descending le
lengthSorter
should be a function.
testString: assert(typeof lengthSorter == 'function', 'lengthSorter
should be a function.');
- - text: lengthSorter(["Here", "are", "some", "sample", "strings", "to", "be", "sorted"])
should return a array.
- testString: assert(Array.isArray(lengthSorter(["Here", "are", "some", "sample", "strings", "to", "be", "sorted"])), 'lengthSorter(["Here", "are", "some", "sample", "strings", "to", "be", "sorted"])
should return a array.');
+ - text: lengthSorter(["Here", "are", "some", "sample", "strings", "to", "be", "sorted"])
should return an array.
+ testString: assert(Array.isArray(lengthSorter(["Here", "are", "some", "sample", "strings", "to", "be", "sorted"])), 'lengthSorter(["Here", "are", "some", "sample", "strings", "to", "be", "sorted"])
should return an array.');
- text: lengthSorter(["Here", "are", "some", "sample", "strings", "to", "be", "sorted"])
should return ["strings", "sample", "sorted", "Here", "some", "are", "be", "to"]
.
testString: assert.deepEqual(lengthSorter(["Here", "are", "some", "sample", "strings", "to", "be", "sorted"]), ["strings", "sample", "sorted", "Here", "some", "are", "be", "to"], 'lengthSorter(["Here", "are", "some", "sample", "strings", "to", "be", "sorted"])
should return ["strings", "sample", "sorted", "Here", "some", "are", "be", "to"]
.');
- text: lengthSorter(["I", "hope", "your", "day", "is", "going", "good", "?"])
should return ["going", "good", "hope", "your", "day", "is", "?","I"]
.
@@ -41,7 +42,7 @@ tests:
beadSort
should be a function.
testString: assert(typeof beadSort == 'function', 'beadSort
should be a function.');
- - text: beadSort([25, 32, 12, 7, 20])
should return a array.
- testString: assert(Array.isArray(beadSort([25, 32, 12, 7, 20])), 'beadSort([25, 32, 12, 7, 20])
should return a array.');
+ - text: beadSort([25, 32, 12, 7, 20])
should return an array.
+ testString: assert(Array.isArray(beadSort([25, 32, 12, 7, 20])), 'beadSort([25, 32, 12, 7, 20])
should return an array.');
- text: beadSort([25, 32, 12, 7, 20])
should return [7, 12, 20, 25, 32]
.
testString: assert.deepEqual(beadSort([25, 32, 12, 7, 20]), [7, 12, 20, 25, 32], 'beadSort([25, 32, 12, 7, 20])
should return [7, 12, 20, 25, 32]
.');
- text: beadSort([38, 45, 35, 8, 13])
should return [8, 13, 35, 38, 45]
.
@@ -45,7 +45,7 @@ tests:
while not InOrder(list) do -Shuffle(list) + Shuffle(list) done +
bogosort
should be a function.
testString: assert(typeof bogosort == 'function', 'bogosort
should be a function.');
- - text: bogosort([25, 32, 12, 7, 20])
should return a array.
- testString: assert(Array.isArray(bogosort([25, 32, 12, 7, 20])), 'bogosort([25, 32, 12, 7, 20])
should return a array.');
+ - text: bogosort([25, 32, 12, 7, 20])
should return an array.
+ testString: assert(Array.isArray(bogosort([25, 32, 12, 7, 20])), 'bogosort([25, 32, 12, 7, 20])
should return an array.');
- text: bogosort([25, 32, 12, 7, 20])
should return [7, 12, 20, 25, 32]
.
testString: assert.deepEqual(bogosort([25, 32, 12, 7, 20]), [7, 12, 20, 25, 32], 'bogosort([25, 32, 12, 7, 20])
should return [7, 12, 20, 25, 32]
.');
- text: bogosort([38, 45, 35, 8, 13])
should return [8, 13, 35, 38, 45]
.
@@ -50,7 +52,7 @@ tests:
function cocktailSort( A : list of sortable items ) do @@ -29,12 +29,11 @@ The cocktail shaker sort is an improvement on the Bubble Sort. -Like the Shell sort, the Comb Sort increases the gap used in comparisons and exchanges. +The Comb Sort is a variant of the Bubble Sort. +Like the Shell sort, the Comb Sort increases the gap used in comparisons and exchanges. Dividing the gap by $(1-e^{-\varphi})^{-1} \approx 1.247330950103979$ works best, but 1.3 may be more practical. Some implementations use the insertion sort once the gap is less than a certain amount. Also seeVariants:
combSort
should be a function.
testString: assert(typeof combSort == 'function', 'combSort
should be a function.');
- - text: combSort([25, 32, 12, 7, 20])
should return a array.
- testString: assert(Array.isArray(combSort([25, 32, 12, 7, 20])), 'combSort([25, 32, 12, 7, 20])
should return a array.');
+ - text: combSort([25, 32, 12, 7, 20])
should return an array.
+ testString: assert(Array.isArray(combSort([25, 32, 12, 7, 20])), 'combSort([25, 32, 12, 7, 20])
should return an array.');
- text: combSort([25, 32, 12, 7, 20])
should return [7, 12, 20, 25, 32]
.
testString: assert.deepEqual(combSort([25, 32, 12, 7, 20]), [7, 12, 20, 25, 32], 'combSort([25, 32, 12, 7, 20])
should return [7, 12, 20, 25, 32]
.');
- text: combSort([38, 45, 35, 8, 13])
should return [8, 13, 35, 38, 45]
.
@@ -81,7 +80,7 @@ tests:
function gnomeSort(a[0..size-1]) @@ -27,12 +27,11 @@ The pseudocode for the algorithm is: endif done-Write a function to implement the above pseudo code. The function should return the sorted array.
gnomeSort
should be a function.
testString: assert(typeof gnomeSort == 'function', 'gnomeSort
should be a function.');
- - text: gnomeSort([25, 32, 12, 7, 20])
should return a array.
- testString: assert(Array.isArray(gnomeSort([25, 32, 12, 7, 20])), 'gnomeSort([25, 32, 12, 7, 20])
should return a array.');
+ - text: gnomeSort([25, 32, 12, 7, 20])
should return an array.
+ testString: assert(Array.isArray(gnomeSort([25, 32, 12, 7, 20])), 'gnomeSort([25, 32, 12, 7, 20])
should return an array.');
- text: gnomeSort([25, 32, 12, 7, 20])
should return [7, 12, 20, 25, 32]
.
testString: assert.deepEqual(gnomeSort([25, 32, 12, 7, 20]), [7, 12, 20, 25, 32], 'gnomeSort([25, 32, 12, 7, 20])
should return [7, 12, 20, 25, 32]
.');
- text: gnomeSort([38, 45, 35, 8, 13])
should return [8, 13, 35, 38, 45]
.
diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/sorting-algorithms-pancake-sort.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/sorting-algorithms-pancake-sort.md
index 0dcdbd5ffd..5b277ec0cc 100644
--- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/sorting-algorithms-pancake-sort.md
+++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/sorting-algorithms-pancake-sort.md
@@ -6,11 +6,11 @@ challengeType: 5
## Description
Before: -6 7 8 9 2 5 3 4 1 +6 7 8 9 2 5 3 4 1@@ -29,8 +29,8 @@ Only one end of the list can be flipped; this should be the low end, but the hig tests: - text:
After: 9 8 7 6 2 5 3 4 1
pancakeSort
should be a function.
testString: assert(typeof pancakeSort == 'function', 'pancakeSort
should be a function.');
- - text: pancakeSort([25, 32, 12, 7, 20])
should return a array.
- testString: assert(Array.isArray(pancakeSort([25, 32, 12, 7, 20])), 'pancakeSort([25, 32, 12, 7, 20])
should return a array.');
+ - text: pancakeSort([25, 32, 12, 7, 20])
should return an array.
+ testString: assert(Array.isArray(pancakeSort([25, 32, 12, 7, 20])), 'pancakeSort([25, 32, 12, 7, 20])
should return an array.');
- text: pancakeSort([25, 32, 12, 7, 20])
should return [7, 12, 20, 25, 32]
.
testString: assert.deepEqual(pancakeSort([25, 32, 12, 7, 20]), [7, 12, 20, 25, 32], 'pancakeSort([25, 32, 12, 7, 20])
should return [7, 12, 20, 25, 32]
.');
- text: pancakeSort([38, 45, 35, 8, 13])
should return [8, 13, 35, 38, 45]
.
@@ -50,7 +50,7 @@ tests:
permutationSort
should be a function.
testString: assert(typeof permutationSort == 'function', 'permutationSort
should be a function.');
- - text: permutationSort([25, 32, 12, 7, 20])
should return a array.
- testString: assert(Array.isArray(permutationSort([25, 32, 12, 7, 20])), 'permutationSort([25, 32, 12, 7, 20])
should return a array.');
+ - text: permutationSort([25, 32, 12, 7, 20])
should return an array.
+ testString: assert(Array.isArray(permutationSort([25, 32, 12, 7, 20])), 'permutationSort([25, 32, 12, 7, 20])
should return an array.');
- text: permutationSort([25, 32, 12, 7, 20])
should return [7, 12, 20, 25, 32]
.
testString: assert.deepEqual(permutationSort([25, 32, 12, 7, 20]), [7, 12, 20, 25, 32], 'permutationSort([25, 32, 12, 7, 20])
should return [7, 12, 20, 25, 32]
.');
- text: permutationSort([38, 45, 35, 8, 13])
should return [8, 13, 35, 38, 45]
.
@@ -48,7 +48,7 @@ tests:
shellSort
should be a function.
testString: assert(typeof shellSort == 'function', 'shellSort
should be a function.');
- - text: shellSort([25, 32, 12, 7, 20])
should return a array.
- testString: assert(Array.isArray(shellSort([25, 32, 12, 7, 20])), 'shellSort([25, 32, 12, 7, 20])
should return a array.');
+ - text: shellSort([25, 32, 12, 7, 20])
should return an array.
+ testString: assert(Array.isArray(shellSort([25, 32, 12, 7, 20])), 'shellSort([25, 32, 12, 7, 20])
should return an array.');
- text: shellSort([25, 32, 12, 7, 20])
should return [7, 12, 20, 25, 32]
.
testString: assert.deepEqual(shellSort([25, 32, 12, 7, 20]), [7, 12, 20, 25, 32], 'shellSort([25, 32, 12, 7, 20])
should return [7, 12, 20, 25, 32]
.');
- text: shellSort([38, 45, 35, 8, 13])
should return [8, 13, 35, 38, 45]
.
@@ -47,7 +47,7 @@ tests:
algorithm stoogesort(array L, i = 0, j = length(L)-1) @@ -33,8 +33,8 @@ The Stooge Sort algorithm is as follows: tests: - text:stoogeSort
should be a function. testString: assert(typeof stoogeSort == 'function', 'stoogeSort
should be a function.'); - - text:stoogeSort([25, 32, 12, 7, 20])
should return a array. - testString: assert(Array.isArray(stoogeSort([25, 32, 12, 7, 20])), 'stoogeSort([25, 32, 12, 7, 20])
should return a array.'); + - text:stoogeSort([25, 32, 12, 7, 20])
should return an array. + testString: assert(Array.isArray(stoogeSort([25, 32, 12, 7, 20])), 'stoogeSort([25, 32, 12, 7, 20])
should return an array.'); - text:stoogeSort([25, 32, 12, 7, 20])
should return[7, 12, 20, 25, 32]
. testString: assert.deepEqual(stoogeSort([25, 32, 12, 7, 20]), [7, 12, 20, 25, 32], 'stoogeSort([25, 32, 12, 7, 20])
should return[7, 12, 20, 25, 32]
.'); - text:stoogeSort([38, 45, 35, 8, 13])
should return[8, 13, 35, 38, 45]
. @@ -54,7 +54,7 @@ tests:```js -function stoogeSort (arr) { +function stoogeSort(arr) { // Good luck! } ``` @@ -66,7 +66,7 @@ function stoogeSort (arr) {```js -function stoogeSort (arr) { +function stoogeSort(arr) { function stoogeSortRecurse(array, i, j) { if (j === undefined) { j = array.length - 1; diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/sorting-algorithms-strand-sort.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/sorting-algorithms-strand-sort.md index d729e7bbf5..69dab8e72f 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/sorting-algorithms-strand-sort.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/sorting-algorithms-strand-sort.md @@ -6,7 +6,7 @@ challengeType: 5 ## Description -Write a function to sort an array using the Strand sort. The function should return the sorted array. +Write a function to sort an array using the Strand sort. The function should return the sorted array. This is a way of sorting numbers by extracting shorter sequences of already sorted numbers from an unsorted list. @@ -22,8 +22,8 @@ This is a way of sorting numbers by extracting shorter sequences of already sort tests: - text:strandSort
should be a function. testString: assert(typeof strandSort == 'function', 'strandSort
should be a function.'); - - text:strandSort([25, 32, 12, 7, 20])
should return a array. - testString: assert(Array.isArray(strandSort([25, 32, 12, 7, 20])), 'strandSort([25, 32, 12, 7, 20])
should return a array.'); + - text:strandSort([25, 32, 12, 7, 20])
should return an array. + testString: assert(Array.isArray(strandSort([25, 32, 12, 7, 20])), 'strandSort([25, 32, 12, 7, 20])
should return an array.'); - text:strandSort([25, 32, 12, 7, 20])
should return[7, 12, 20, 25, 32]
. testString: assert.deepEqual(strandSort([25, 32, 12, 7, 20]), [7, 12, 20, 25, 32], 'strandSort([25, 32, 12, 7, 20])
should return[7, 12, 20, 25, 32]
.'); - text:strandSort([38, 45, 35, 8, 13])
should return[8, 13, 35, 38, 45]
. @@ -43,7 +43,7 @@ tests:```js -function strandSort (list) { +function strandSort(list) { // Good luck! } ``` @@ -55,7 +55,7 @@ function strandSort (list) {```js -function strandSort (list) { +function strandSort(list) { function merge(left, right) { var result = [];