I am trying to generate a array containing all two letter word combinations.
What would be the best way to generate it.
Could someone help me out?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As
steenslagpoints out, the quickest way isIf your alphabet isn’t ‘a’ through ‘z’, though, you can use
Array#repeated_combination:Or, as
Mladenpoints out:Note:
repeated_combinationis available in Ruby 1.9.2 or withrequire 'backports/1.9.2/array/repeated_combination'from mybackportsgem.