Created
September 9, 2013 23:09
-
-
Save mattbierner/6502727 to your computer and use it in GitHub Desktop.
Generate randomly ordered set of indices in a range.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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