You must fill an array with every number from 0-n inclusive. No numbers should repeat. However they must be in a random order.


All standard rules and standard loopholes are banned

The array must be generated pseudo-randomly. Every possible permutation should have a equal probability.


n in any way allowed in the I/O post on meta.


The array of numbers scrambled from 0-n inclusive.

  • \$\begingroup\$ the output can be separated by newlines? \$\endgroup\$ – DrnglVrgs May 30 '17 at 20:48
  • \$\begingroup\$ @Riley opps that was meant to be gone sorry. \$\endgroup\$ – Christopher May 31 '17 at 0:48
  • \$\begingroup\$ @DrnglVrgs yes it can \$\endgroup\$ – Christopher May 31 '17 at 0:48
  • \$\begingroup\$ By "numbers" I assume you mean "integers"? \$\endgroup\$ – Zacharý Aug 10 '17 at 1:12
  • 1
    \$\begingroup\$ @KevinCruijssen IMO lists = array but with searching support. So sure use a list \$\endgroup\$ – Christopher Aug 11 '17 at 14:59

32 Answers 32


JavaScript ES6, 60 bytes, uniform distribute


for(i=0; i<1000; i++) k=f(2), s[k]=-~s[k];
for(i in s) console.log(i, s[i]);


AWK, 82 bytes


Try it online!

AWK doesn't have a built-in shuffle, so this is the best I could come up with.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.