From: "Christoffer Lernö" Date: 2008-06-18T23:41:11+09:00 Subject: Re: little problem (google hiring puzzle) On 15 Jun 2008, at 18:59, ex wrote: > Hi guys, I wonder if someone can find a pure ruby solution instead of > mine (I still can get out of my *loop* mind): This works a = [4, 3, 2, 1, 2] x = a.inject([1]) { |sum, i | sum << sum.last * i } x.pop y = a.reverse.inject([1]) { |sum, i| sum << sum.last * i } y.pop y.reverse! o = [] a.length.times { |i| o[i] = x[i] * y[i] } p o