> Btw. does anybody know if this behavior is defined
> somewhere (adding elements to an Array while
> iterating over it):
> irb(main):001:0> (a=[0]).each { |i| a << i+1 if i < 10 }; a
> => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

If you just want to accumualte an array, here is a snippet from the
Programming Ruby HTML book:

(1..10).to_a  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

-- Timothy
just realized I should have added start_pos to my initial forbidden
array so the algorithm wouldn't try to double back.