From: Josh Cheek Date: 2009-11-16T15:21:24+09:00 Subject: Re: How do I get a random number between two random numbers? --000e0cd296acbd7dc4047877047e Content-Type: text/plain; charset=ISO-8859-1 On Sat, Nov 14, 2009 at 8:54 PM, Alex Untitled wrote: > I want to create a program that asks you to guess a number between two > numbers. The problem is that I can't figure out how to make the numbers > that you're guessing between random and have the random number you are > guessing between those two numbers. Does anybody know how to do this? > -- > Posted via http://www.ruby-forum.com/. > > # How about something like: max = 100 low , high = [ rand(max) , rand(max) ].sort difference = high - low middle = low + rand(difference).to_i #to_i for if low and high have same value puts "low = #{low}" puts "middle = #{middle}" puts "high = #{high}" --000e0cd296acbd7dc4047877047e--