fork download
  1. class RandomSequence
  2. def initialize(limit,num)
  3. @limit,@num = limit,num
  4. end
  5.  
  6. def each
  7. @num.times { yield (rand * @limit).floor }
  8. end
  9. end
  10.  
  11. i = 15
  12. RandomSequence.new(10,4).each do |num|
  13. i = num if i < num
  14. end
  15. print i
Success #stdin #stdout 0.02s 7456KB
stdin
Standard input is empty
stdout
15