2012-11-01 14 views

Antwort

8

Als schnelle Einzeiler:

rands = (0..10).to_a.shuffle[0, Random.rand(0..10)] 
+0

Chowlett: Nice one :) –

+0

ich es nicht oft sagen Genug - ich liebe wirklich die Art und Weise wie Ruby dich so etwas machen lässt! – Chowlett

+0

Ich stelle mir vor, dass es in Python noch einfacher sein könnte :) –

4

Wenn Sie mit Ruby 1.9 ein weiterer Einzeiler mit Array#sample

rands = (0..10).to_a.sample(­Random.ran­­d(0..10)) 
+0

auch super! Vielen Dank –