Find the amount of vowels, words and letters in the sentence

736 Views Asked by At

This is the problem which I have to solve by using a programming language but it looks very hard for me to form an algorithm because all variables X for letters, Y for vowels and Z for words are depended on each other. By saying this I mean: "In this sentence we have X letters, Y vowels and Z words." This is the simple looking problem but the variables have to be written in words (eleven, twenty one...) . If we won't count variables in the sentence we will find out that there are 9 words. But if we express the amount of words by word itself the amount of words will change and become 10 (9 default + Z expression. What if we decide to calculate the amount of letters? Default value would be 41 + the amount of letters representing variable X and Z so the number would rise. If the number of X raises then we need to change it and keep in mind that the amount of letters representing new value would effect on X and possibly Z itself. The problem seems easier when we have one sentence like: " In this sentence we have X vowels." Let's assume that M is the number of vowels in the word X. The function should look like M=X-10. F(X)=M graph represents values from 11 to infinity of the vowels in the X values. If we draw the M=X-10 function on the F(X) graph the intersection (if avaible) between M's value and F(X) probably would be the answer for this question. But it seems hard to imagine 3 dependable variables on each other. The solution for the short sentence is mine and might be wrong.

1

There are 1 best solutions below

0
On BEST ANSWER

Perhaps what you're looking for is all of the solutions $(X,Y,Z)$ (if any exist) that produce a true statement when $X,Y,Z$ are written out in the following sentence: "In this sentence we have X letters, Y vowels and Z words."

The possible values for the numbers are limited.

Single-word numbers mean $12$ words. If $X,Y$ are each two-word numbers then you can have up to $14$ words. Thus we note that twelve has $6$ letters and $2$ vowels, thirteen has $8$ letters and $3$ vowels, and fourteen has $8$ letters and $4$ vowels.

This gives the number of letters $X$ as $47$ or $49$, plus the length of $X$ and $Y$. The maximum length of a number above $49$ but less than $100$ is $12$ letters, so the upper limit for the number of letters is $73$. (Going into the hundreds doesn't add enough letters for the statement to be true.)

If the length of $(X,Y,Z)$ written out are three letters apiece, that brings the total number of letters up to $50$.

I see $14$ vowels. Writing out $Z$ gives another $2$ to $4$. Writing out $Y$ gives at least another $2$ (from twenty). Writing out $X$ will give at least another $2$, so we're at least in the twenties with the vowels.

Twenty through twenty-nine have between two and four vowels, and between six and eleven letters. All of the numbers between $49$ and $73$ written out have at most $5$ vowels, so we must be in the twenties for the number of vowels.

This means that twenty is part of the answer (written out in $Y$). So we have either $53$ or $55$ letters, plus the length of the other part of $Y$, plus the length of $X$.

If $Z$ is $12$ then $Y$ must be $20$ (one word). That would force $X$ to be $60$ or $70$ (one word), but neither of those work. So $Z$ must be $13$ or $14$.

If $Z$ is $13$ then we'll need either $Y$ to be $20$ or $X$ to be $60$ or $70$, but not both. If $Y$ is $20$ then $X$ needs to contain only one vowel, which doesn't work. If $X$ is $60$ or $70$ then $Y$ needs to contain zero or one vowels, which doesn't work, either.

Therefore, if there is a solution, $Z$ must be $14$.

Now it's just a matter of checking the values of $Y$ to see if there are corresponding values of $X$ that work.

We already have $20$ vowels not including $X$ or the other part of $Y$. $X$ will have at least $3$ vowels, and the other part of $Y$ will have at least $1$, so $Y$ is at least $24$.

If $Y=24$, then $X$ must have two vowels, which doesn't work since sixty is the only number in that range with two vowels, and that's a single word.

If $Y=25$, then $X$ must have three vowels and must be greater than $59$. $62$ and $66$ have three vowels, but neither gives the correct total number of letters.

If $Y=26$, $X$ must have five vowels. $71$ and $73$ are the only numbers in the desired range that have five vowels. Unfortunately, neither has the right number of letters (we need $13$, and seventy-one has $10$ and seventy-three has $12$).

If $Y=27$, $X$ must again have five vowels. $71$ and $73$ are the only numbers in the desired range that have five vowels. Unfortunately, neither has the right number of letters (we need $11$).

If $Y=28$ or $Y=29$ we need $X$ to have more than five vowels, and there are none.

Therefore, I conclude that there are no solutions $(X,Y,Z)$ that work.