ruby solver now performs solution in (near) linear time