Lexographical generation in ruby