initial answer to accumulate in ruby