ruby -e'p"BCB".split(//).map{|b|"A"..b}.inject{|a,b|a.map{|x|b.map{|y|x+y}}.flatten}'
Mostly this was just removing unneeded spaces. I also switched puts to p, (changes the output, but Scott had already changed the output so I thought that fair), and used split rather than an unpack.
And for those who haven't bothered to understand the algorithm, here is a commented version of the one-liner.
\nputs \\\n "BCB".split( # Take the string and split it\n // # on the spaces between strings\n ).map{|b| # foreach character b that you get\n "A"..b # make an array "A"..b\n }.inject{|a,b| # foreach of those arrays, let a be the partial\n # answer so far and b be next array (the\n # first array is the first partial answer)\n a.map{|x| # each x in a turns into\n b.map{|y| # an array of turning each y in b into\n x+y # concatenate x and y\n } \n }.flatten # and then flatten the array of arrays into a\n # single-level array of strings\n } # the last partial answer is our full one\n
BTW it may be me, but I find the Ruby version much more readable than the Python. My guess is that I am reacting to the fact that all of the logic is naturally reading left to right, top to bottom.
Cheers,
Ben