Prasanth Ravi wrote:
> Aaron D. Gifford wrote:
>> Ruby 1.9: 34 characters
>> 
>> eval(gets.scan(/(?:^| )(\d+)/)*?+)
>> 
>> Aaron out
> 
> tx aaron this is by far the shortest code ive seen...

A variation:

p eval gets.split(/ |-\d+/)*?+

Siep
-- 
Posted via http://www.ruby-forum.com/.