This is what you need:
a = ["ABC","DEF", "GHI"]
a.map(&:chars).reduce(&:product).map(&:join)
By the way, you made some errors in your example output, there should never be strings starting with an E or an F according to your specification. So I suppose instead of "ECH", "ECI", "FCG", "FCH", "FCI"
you meant "CEH", "CEI", "CFG", "CFH", "CFI"
.
Edit:
chars
returns an Enumerator, not an array, and in Ruby versions before 2.0 those don't have a product
method. So in those versions, just use a to_a
like this:
a.map(&:chars).map(&:to_a).reduce(&:product).map(&:join)