Generate random numbers without repeating a value: Difference between revisions
Generate random numbers without repeating a value (view source)
Revision as of 14:14, 7 December 2023
, 5 months ago→{{header|Wren}}: Tidied alternative version.
m (→{{header|Wren}}: Minor tidy) |
m (→{{header|Wren}}: Tidied alternative version.) |
||
Line 1,193:
<br>
Alternatively and far more efficiently, we can simply create a list of the required numbers and randomly shuffle them. Wren has a built-in function for this which uses the Fisher-Yates (aka Knuth) shuffle.
<syntaxhighlight lang="
import "./fmt" for Fmt
var rand = Random.new()
|