Generate random numbers without repeating a value: Difference between revisions
Content added Content deleted
m (→{{header|Wren}}: Minor tidy) |
m (→{{header|Wren}}: Tidied alternative version.) |
||
Line 1,193: | Line 1,193: | ||
<br> |
<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. |
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=" |
<syntaxhighlight lang="wren">import "random" for Random |
||
import "/fmt" for Fmt |
import "./fmt" for Fmt |
||
var rand = Random.new() |
var rand = Random.new() |