Talk:Generate random numbers without repeating a value

From Rosetta Code
Revision as of 08:53, 26 August 2021 by PureFox (talk | contribs) (→‎Why not use shuffle: Further comment.)

Why not use shuffle

Knuth_shuffle

That's what I'd do in practice though the task is to generate the random numbers individually without repetition so that's what I've done. --PureFox (talk) 17:58, 24 August 2021 (UTC)
There are times you have to read between the lines: in this case what was asked for is almost certainly not what was actually wanted. I placed more emphasis on the "Try your best not to make the process take too long at runtime." part, which to me means not generating/testing/discarding potentially thousands of numbers, and instinctively used shuffle() as you suggest, more in line with the Julia, Raku, and REXX entries. --Pete Lomax (talk) 03:06, 26 August 2021 (UTC)
Well, if that's what the author intended, the task description seems a very long-winded way of saying: "create a list of the first 20 positive integers and randomly shuffle them". Anyway, as that seems to be the consensus view, I've added alternative implementations to my own efforts. --PureFox (talk) 08:53, 26 August 2021 (UTC)