Skip to content

Instantly share code, notes, and snippets.

@mattbierner
Created September 9, 2013 23:09
Show Gist options
  • Save mattbierner/6502727 to your computer and use it in GitHub Desktop.
Save mattbierner/6502727 to your computer and use it in GitHub Desktop.
Generate randomly ordered set of indices in a range.
function range(start, end) {
var indicies = [], out = [];
for (var i = start; i < end; ++i)
indicies.push(i);
while (indicies.length) {
var index = Math.floor(Math.random() * indicies.length);
out.push(indicies[index]);
indicies.splice(index, 1);
}
return out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment