Find Number Well Formed Words Strings Given Length Wordlen Consist Alphabets Z Number Con Q43818419
Find the number of “well-formed” words (or strings) of a givenlength (wordLen) which consist of alphabets [a to z]. The
number of consecutive vowels that can occur in a well-formed stringmust not exceed a given value (max Vowels).
complete the function below:
#include <bits/stdc++.h>
int calculateWays(int wordlen,int maxvowels)
{
}
17. String Patterns Find the number of “well-formed” words (or strings) of a given length (wordLen) which consist of alphabets (a to z]. The number of consecutive vowels that can occur in a well-formed string must not exceed a given value (maxVowels). Vowels (v): {a, e, i, o, u}, Consonants (c): Remaining 21 alphabets. Example: 1. wordLen = 1 and maxVowels = 0, there are 21 possibilities, one for each consonant c. Pattern: {c} 21 2. wordLen = 1 and maxVowels = 1, there are 26 possibilities, one for each alphabet. 21 3. wordLen = 4 and maxVowels = 0, there are (21*21*21* 21) = 194,481 possibilities. Pattern: {cccc} cccc 21 21 21 21 4. wordLen = 4 and maxVowels = 1, there are 412,776 possibilities as shown below: {CCCC, VCCC, CVCC, CCVC, CCCV, VCVC, CVCV} cccc 21 21 21 21 vccccvccccvccccv 5 21 21 21 21 5 21 21 21 21 5 21 21 21 21 5 Example: 1. wordLen = 1 and maxVowels = 0, there are 21 possibilities, one for each consonant c. Pattern: (c) C 21 2. wordLen = 1 and maxVowels = 1, there are 26 possibilities, one for each alphabet. VOC 21 3. wordLen = 4 and maxVowels = 0, there are (21.21.21. 21) = 194,481 possibilities. Pattern: {CCCC) cccc 21 21 21 21 4. wordLen = 4 and maxVowels = 1, there are 412,776 possibilities as shown below: {cccc, VCCC, CVCC, CCVC, CCCV, VCVC, cvcv) cccc 21 21 21 21 v |с |с | cc v cccc v cccc v 5 21 21 21 21 5 21 21 21 21 5 21 21 21 21 5 vcvccvc v 5 21 5 21 21 5 21 5 (21 • 21 * 21 * 21) + (5 * 21 * 21. 21) + (21 *5*21* 21) + (21 * 21*5*21) + (21 * 21 * 21 * 5) + (5 * 21*5*21) + (21*5* 21 * 5) = 412,776 possible solutions. The result may get very large, so return the answer modulo (109+7). Function Description The result may get very large, so return the answer modulo (109+7). Function Description Complete the function calculateWays in the editor below. The function must return an integer that denotes the number of well formed strings that can be created, modulo 1000000007, ie. (109+7). calculateWays has the following parameter(s): wordLen: the length of the words to create maxVowels: the maximum number of consecutive vowels allowed in a word Constraints 1 s wordLen s 2500 O s maxVowels sn Input Format Format for Custom Testing Input from stdin will be processed as follows and passed to the function. The first line contains an integer wordLen, the length of the words to create. The next line contains an integer maxVowels, maximum number of consecutive vowels allowed. Sample Case 0 Sample Input o Sample Output o 651 Explanation o wordLen = 2 maxVowels = 1 Words take the form {vc, cv, cc). There is a vowel in the first position, the second position or no position. The total different words possible is (5 * 21) + (21 * 5) + (21 * 21) = 651 and 651 modulo 1000000007 = 651. Show transcribed image text 17. String Patterns Find the number of “well-formed” words (or strings) of a given length (wordLen) which consist of alphabets (a to z]. The number of consecutive vowels that can occur in a well-formed string must not exceed a given value (maxVowels). Vowels (v): {a, e, i, o, u}, Consonants (c): Remaining 21 alphabets. Example: 1. wordLen = 1 and maxVowels = 0, there are 21 possibilities, one for each consonant c. Pattern: {c} 21 2. wordLen = 1 and maxVowels = 1, there are 26 possibilities, one for each alphabet. 21 3. wordLen = 4 and maxVowels = 0, there are (21*21*21* 21) = 194,481 possibilities. Pattern: {cccc} cccc 21 21 21 21 4. wordLen = 4 and maxVowels = 1, there are 412,776 possibilities as shown below: {CCCC, VCCC, CVCC, CCVC, CCCV, VCVC, CVCV} cccc 21 21 21 21 vccccvccccvccccv 5 21 21 21 21 5 21 21 21 21 5 21 21 21 21 5
Example: 1. wordLen = 1 and maxVowels = 0, there are 21 possibilities, one for each consonant c. Pattern: (c) C 21 2. wordLen = 1 and maxVowels = 1, there are 26 possibilities, one for each alphabet. VOC 21 3. wordLen = 4 and maxVowels = 0, there are (21.21.21. 21) = 194,481 possibilities. Pattern: {CCCC) cccc 21 21 21 21 4. wordLen = 4 and maxVowels = 1, there are 412,776 possibilities as shown below: {cccc, VCCC, CVCC, CCVC, CCCV, VCVC, cvcv) cccc 21 21 21 21 v |с |с | cc v cccc v cccc v 5 21 21 21 21 5 21 21 21 21 5 21 21 21 21 5 vcvccvc v 5 21 5 21 21 5 21 5 (21 • 21 * 21 * 21) + (5 * 21 * 21. 21) + (21 *5*21* 21) + (21 * 21*5*21) + (21 * 21 * 21 * 5) + (5 * 21*5*21) + (21*5* 21 * 5) = 412,776 possible solutions. The result may get very large, so return the answer modulo (109+7). Function Description
The result may get very large, so return the answer modulo (109+7). Function Description Complete the function calculateWays in the editor below. The function must return an integer that denotes the number of well formed strings that can be created, modulo 1000000007, ie. (109+7). calculateWays has the following parameter(s): wordLen: the length of the words to create maxVowels: the maximum number of consecutive vowels allowed in a word Constraints 1 s wordLen s 2500 O s maxVowels sn
Input Format Format for Custom Testing Input from stdin will be processed as follows and passed to the function. The first line contains an integer wordLen, the length of the words to create. The next line contains an integer maxVowels, maximum number of consecutive vowels allowed. Sample Case 0 Sample Input o Sample Output o 651 Explanation o wordLen = 2 maxVowels = 1 Words take the form {vc, cv, cc). There is a vowel in the first position, the second position or no position. The total different words possible is (5 * 21) + (21 * 5) + (21 * 21) = 651 and 651 modulo 1000000007 = 651.
Expert Answer
Answer to Find the number of “well-formed” words (or strings) of a given length (wordLen) which consist of alphabets [a to z]. Th…
OR