Florian Aann wrote:
> puts eval(gets.gsub(/-\d+|[^0-9]+/, '+')<<'+0')
> 
> Am 08.03.2010 um 22:10 schrieb Prasanth Ravi:

irb(main):001:0> puts eval(gets.gsub(/-\d+|[^0-9]+/, '+')<<'+0')
1 2 3 4
10
=> nil
irb(main):002:0> puts eval(gets.gsub(/-\d+|[^0-9]+/, '+')<<'+0')
1 -2 3 4
10
=> nil
irb(main):003:0> puts eval(gets.gsub(/-\d+|[^0-9]+/, '+')<<'+0')
1 -2 -34 5
42
=> nil
irb(main):004:0> puts eval(gets.gsub(/-\d+|[^0-9]+/, '+')<<'+0')
-234
0
=> nil
irb(main):005:0> puts eval(gets.gsub(/-\d+|[^0-9]+/, '+')<<'+0')
-2 -3 -4
7
=> nil
irb(main):006:0> puts eval(gets.gsub(/-\d+|[^0-9]+/, '+')<<'0')
1 2 3 43
49
=> nil
irb(main):007:0> puts eval(gets.gsub(/-\d+|[^0-9]+/, '+')<<'0')
1 -2 3 4
10
=> nil


it's shorter code(45 chars) but i think negative numbers also get added 
to result( or not- check case 5), seems can't get below 35
-- 
Posted via http://www.ruby-forum.com/.