Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,18 @@
var countSort = function(arr, min, max) {
var i, z = 0, count = [];
for (i = min; i <= max; i++) {
count[i] = 0;
}
for (i=0; i < arr.length; i++) {
count[arr[i]]++;
}
for (i = min; i <= max; i++) {
while (count[i]-- > 0) {
arr[z++] = i;
}
}
}

View file

@ -0,0 +1,13 @@
// Line breaks are in HTML
var i, ages = [];
for (i = 0; i < 100; i++) {
ages.push(Math.floor(Math.random() * (141)));
}
countSort(ages, 0, 140);
for (i = 0; i < 100; i++) {
document.write(ages[i] + "<br />");
}