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.