Generate random numbers without repeating a value: Difference between revisions
Content deleted Content added
Added Sidef |
Drkameleon (talk | contribs) Added Arturo implementation |
||
Line 100:
14 2 1 18 10 7 13 11 17 4 20 9 6 3 16 19 5 15 12 8
</pre>
=={{header|Arturo}}==
<lang rebol>generateUniqueRandoms: function [][
result: new []
while [20 > size result][
rand: sample 1..20
if not? in? rand result ->
'result ++ rand
]
return result
]
loop 3 'x [
print generateUniqueRandoms
]</lang>
{{out}}
<pre>16 6 1 4 7 18 19 3 9 10 12 5 8 15 14 17 11 13 20 2
12 16 3 7 4 15 6 14 19 13 10 8 11 2 17 5 9 18 20 1
5 6 18 12 4 3 19 14 13 11 2 7 17 9 10 8 20 16 1 15</pre>
=={{header|AWK}}==
|