RosettaCodeData/Task/Random-number-generator-device-/Ruby/random-number-generator-device-.rb

6 lines
169 B
Ruby
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
require 'securerandom'
SecureRandom.random_number(1 << 32)
#or specifying SecureRandom as the desired RNG:
p (1..10).to_a.sample(3, random: SecureRandom) # =>[1, 4, 5]