Skip to main content
3 of 3
Golfed some unnecessary characters (mostly from the list command).
bmarks
  • 2.1k
  • 11
  • 13

STATA, 161

di _r(s) set ob wordcount($s) token $s g a=0 foreach x in $s{ gl j=floor(runiform()*_n)+1 replace a=`$j' if word($s,_n)=`x' replace a=`x' if word($s,_n)=`$j' } l 

Expects input as space separated numbers. I can remove the headers and observation numbers from the output if you would like, but otherwise this is shorter.

bmarks
  • 2.1k
  • 11
  • 13