Tom Sawyer wrote:

> damn! i went to measure the speed on that one liner, but alas i run on
> stable.
> 

?

I don't know how your measuring them, but I think it'd be quite difficult 
to compare them fairly.  Each algorithm probably goes through the
search-space in a different order, making different algorithms
discover a solution quicker than others for different inputs.
Granted, the recursive types may have an edge since they effectively
use the ruby stack as a search-tree, making the underlying C do more
of the work for them.  (?)

> what's inject do?

Inject is explained in the Pickaxe book in the chapter "Containers,
Blocks, and Iterators."  I changed #inject to #find, though, since
it's cleaner, shorter, and supported in 1.6.

Having taken another look at Avi's now though, I realize our solutions
are essentially the same.  There probably isn't a better way short of
introducing search heuristics.

(Note: I'm viewing the problem as a constraint satisfaction problem,
hence terms like "search-tree" and "search heuristics".  Search Google
for an explanation of CSPs.)

> 
> also, it would be nice to have a brief description of the main idea
> behind the solution. (all of the solutions, actually)
> 

Ok, I put a short explanation on mine.