Generate random numbers without repeating a value: Difference between revisions
Content added Content deleted
Catskill549 (talk | contribs) (added AWK) |
|||
Line 399: | Line 399: | ||
<pre> |
<pre> |
||
randperm(20) = [20, 2, 5, 6, 18, 14, 12,4, 13, 7, 15, 3, 19, 17, 1, 9, 16, 11, 10] |
randperm(20) = [20, 2, 5, 6, 18, 14, 12,4, 13, 7, 15, 3, 19, 17, 1, 9, 16, 11, 10] |
||
</pre> |
|||
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
|||
<lang Mathematica>Table[RandomSample[Range@20], {5}] // TableForm</lang> |
|||
{{out}}<pre> |
|||
11 5 1 16 3 8 12 4 14 19 9 6 7 13 17 2 15 10 18 20 |
|||
10 20 17 3 18 7 8 9 5 11 13 15 14 2 1 4 6 12 16 19 |
|||
14 4 7 8 17 9 19 20 18 16 1 10 2 6 13 15 3 5 12 11 |
|||
18 9 10 4 13 11 12 1 20 5 19 7 14 6 15 2 17 3 16 8 |
|||
16 3 4 10 12 9 14 7 15 17 2 18 6 5 19 20 8 13 11 1 |
|||
</pre> |
</pre> |
||