From: jko170 Date: 2009-01-22T03:23:22+09:00 Subject: Re: 10 numbers in between 2 numbers On Jan 20, 5:19 pm, Tim Hunter wrote: > jko170 wrote: > > On Jan 19, 10:05 pm, James Gray wrote: > >> On Jan 19, 2009, at 9:58 PM, jko170 wrote: > > >>> How can I get an array of 10 numbers in between two numbers? > >>> (1..500).to_a > >> I guess it depends on which ten numbers you want, but here's one way: > > >>  >> (1..500).enum_for(:step, 50).to_a > >> => [1, 51, 101, 151, 201, 251, 301, 351, 401, 451] > > >> James Edward Gray II > > > Yeah, the end numbers need to be included in the array of 10. > > Requirements: 10 numbers, evenly distributed, first and last numbers in > the array. > > require 'pp' > > first, last = ARGV[0].to_f, ARGV[1].to_f > numbers = [] > incr = (last - first) / 9.0 > n = first > 10.times do >    numbers << n >    n += incr > end > pp numbers > > -- > RMagick:http://rmagick.rubyforge.org/ Thank you very much Tim! Works perfectly.