Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function generate(size) {
- var arry = ints(size);
- return compute(arry, []);
- }
- function compute(src, dest) {
- if (src.length == 0) {
- return dest;
- }
- dest = dest.concat(src.splice(random(src.length)));
- return compute(src, dest);
- }
- function random(n) {
- return Math.floor(Math.random() * n);
- }
- // Creates List of size ints from 0-size - 1
- function ints(size) {
- return (size == 1) ? [0] : ints(size - 1).concat(size - 1);
- }
- console.log(generate(10));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement