From: Florian Aßmann on
interesting...

ree-1.8.7-2010.01 > puts eval(gets.gsub(/(?:-\d|[^0-9])+/, '+')<<'+0')
1 2 3 -4
6
=> nil
ree-1.8.7-2010.01 > puts eval(gets.gsub(/(?:-\d|[^0-9])+/, '+')<<'+0')
1 -2 3 4
8
=> nil

ol' ruby?

Am 09.03.2010 um 04:39 schrieb Prasanth Ravi:

> Florian Aßmann 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/.
>


From: Prasanth Ravi on
Florian Aßmann wrote:
> interesting...
>
> ree-1.8.7-2010.01 > puts eval(gets.gsub(/(?:-\d|[^0-9])+/, '+')<<'+0')
> 1 2 3 -4
> 6
> => nil
> ree-1.8.7-2010.01 > puts eval(gets.gsub(/(?:-\d|[^0-9])+/, '+')<<'+0')
> 1 -2 3 4
> 8
> => nil
>
> ol' ruby?
>
> Am 09.03.2010 um 04:39 schrieb Prasanth Ravi:

irb(main):010:0> puts eval(gets.gsub(/(?:-\d|[^0-9])+/, '+')<<'+0')
3 4 -5
7
=> nil
irb(main):011:0> puts eval(gets.gsub(/(?:-\d|[^0-9])+/, '+')<<'+0')
-56
6
=> nil

was it -(56) or -5 & 6 ? :D
--
Posted via http://www.ruby-forum.com/.

From: Robert Dober on
On Wed, Mar 10, 2010 at 9:07 AM, Prasanth Ravi <dare.take(a)gmail.com> wrote:
> Florian Aßmann wrote:
>> interesting...
>>
>> ree-1.8.7-2010.01 > puts eval(gets.gsub(/(?:-\d|[^0-9])+/, '+')<<'+0')
>> 1 2 3 -4
>> 6
>>  => nil
>> ree-1.8.7-2010.01 > puts eval(gets.gsub(/(?:-\d|[^0-9])+/, '+')<<'+0')
>> 1 -2 3 4
>> 8
>>  => nil
>>
>> ol' ruby?
>>
>> Am 09.03.2010 um 04:39 schrieb Prasanth Ravi:
>
> irb(main):010:0> puts eval(gets.gsub(/(?:-\d|[^0-9])+/, '+')<<'+0')
> 3 4 -5
> 7
> => nil
> irb(main):011:0> puts eval(gets.gsub(/(?:-\d|[^0-9])+/, '+')<<'+0')
> -56
> 6
> => nil
>
> was it -(56) or -5 & 6 ? :D
> --
> Posted via http://www.ruby-forum.com/.
>
>
1 -2 8 is nice too ;)
Even spec your golfs !!!


--
Learning without thought is labor lost; thought without learning is perilous.”
--- Confucius