Skip to main content
4 of 4
Avoid first 139 effect.
Stephen Kitt
  • 481.4k
  • 60
  • 1.2k
  • 1.4k

If you want to do this only using commonly-available tools (at least on Linux distributions), the most efficient way is probably to ask shuf:

shuf -i 1-139 -n 1519 -r

This produces 1519 numbers randomly chosen between 1 and 139.

To ensure that each place gets one person, shuffle 139 numbers first without repeating:

shuf -i 1-139
shuf -i 1-139 -n 1380 -r

To reduce the “first 139” effect (the first 139 people would all end up in different places), shuffle all this again:

(shuf -i 1-139; shuf -i 1-139 -n 1380 -r) | shuf
Stephen Kitt
  • 481.4k
  • 60
  • 1.2k
  • 1.4k