I have a language consisting of the words having exactly two “1” and three “0”. How can I efficiently enumerate the finite set of all words of this language?
Share
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.
Easy, write the number 11100, calculate the number of permutation of this value = n! = 5!,
divide by the number of permutation of the 3 1’s = 3! and the number of permutation of 0’s = 2! => 5! / (2! * 3!) = 120 / (6 * 2) = 10
Now if you need the actual values, for an arbitrary language, you have no other choice but to use a backtracking algorithm.
For this particular case, you can easily build a simple algorithm generating this language:
Here’s an example using python