Moving Average by mgrosso

a=[];ARGF.each{|x|a=(a<<x.split(' ')[1].to_f).slice!(-5,5)||a;puts "%s Average: %.1f\n"%[x.chomp,a.reduce(&:+)/a.size]}\x0d

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page