Prasanth Ravi wrote:
> tx for the reply, i originally used
> y=0
> gets.split.each{ |x|
>   z=x.to_i
>   y+=z if z>0
> }
> print y

You can save a char by replacing

y=0;s.split.each{|x|z=x.to_i;y+=z if z>0}

with

y=0;s.split.each{|x|y+=x.to_i if /-/!~x}

but this is even shorter

y=0;s.scan(/ \d+|^\d+/){|x|y+=x.to_i}