Generate random numbers without repeating a value: Difference between revisions

m
→‎{{header|Factor}}: change wording
(→‎{{header|Factor}}: add some different approaches)
m (→‎{{header|Factor}}: change wording)
Line 30:
 
=={{header|Factor}}==
Generating a random permutation of 1..n20:
{{works with|Factor|0.99 2021-06-02}}
<lang factor>USING: kernel math.combinatorics math.ranges prettyprint random
Line 43:
{ 7 10 12 9 5 8 20 14 18 4 13 3 17 16 19 6 15 1 2 11 }
</pre>
Shuffling 1..n20:
{{works with|Factor|0.99 2021-06-02}}
<lang factor>USING: math.ranges prettyprint random vectors ;
Line 52:
V{ 20 7 8 17 18 1 15 13 12 10 3 14 19 2 5 9 16 11 6 4 }
</pre>
Sampling n elements from 1..n20:
{{works with|Factor|0.99 2021-06-02}}
<lang factor>USING: math.ranges prettyprint random ;
1,827

edits