From: Harry Kakueki Date: 2012-02-04T12:02:09+09:00 Subject: Re: 4 random numbers take highest 3 and add them together. On Sat, Feb 4, 2012 at 9:43 AM, h4y4shi 13bladex wrote: > I want to get 4 random numbers. The numbers will be between 1-6. I want > to disregard the smallest number and add the three biggest numbers > together. So far I wrote some ruby that I thought would do this but I > keep getting an error. > If you don't like inject, this is even shorter and easier to understand. It's not very flexible but..... If you always have 4 numbers and always want to add the largest 3 numbers, r = [2,4,1,5] p r[0]+r[1]+r[2]+r[3]-r.min Harry