From: w_a_x_man Date: 2010-11-05T15:56:43+09:00 Subject: Re: Emacs/putty code help On Nov 5, 12:12 am, Thierry Ntoh yuh wrote: > Please someone help me with this ruby code on putty/emacs > Thanks > > Write a statistical program in Ruby to: > > a)  Input the name of a data file from the command line arguments. > > b)  Input floating-point numbers from the data file. > > c)  Calculate and output the mean.  This is the average, or the sum of > the >     values divided by the number of values. > > d)  Calculate and output the median.  This is the value such than half > the >     values are larger and half are smaller.  If you have an even number > of >     values use either middle value or the average of the two middle > values. > > -- > Posted viahttp://www.ruby-forum.com/. I wonder what your teacher will think of this. ruby -e"a=gets(nil).scan(/[-\d.]+/).map &:to_f;p a. reduce{|s,x|s+x}/a.size,a.sort[a.size/2]"