Back to General discussions forum
Hi everybody.
I have a problem with Funny Words Generator: I created a C# code for solving the problem, but using the examples, the needed answer is correct in case of the first e.g. 8 characters, but after that the program is not usable. I realised that I had to check if the word started with a consonant, but I have not got any idea to find which value will follow the previous - correct - one. Could somebody give me advice?
Thank you for replying.
Are you resetting the LCG (linear congruential generator) between words? That could be your problem. Once it starts giving you random numbers, you keep using the same one for all the words.
No, I do not reset it. I took the letters to a string, which length was the sum of the lengths of the words (I made a FOR cycle, and its last value was the sum of the lengths). After that I seperated the string according to the input data.
http://kepkezelo.com/images/1uxrqfva3rwz0lnhwp.png
The words must all start with a consonant. I don't know which method you are using to alternate between vowels and consonants, but you must base it on the position your are at in the current word.
It is OK, I understand, but it works not correctly: I changed the code according to your explanation, but the following letter is always a consonant (because in this case the value is even, and the following value is odd). What would be the next number?
You say you have a string which is the sum of the length of the words; you cannot do it like that. It will be easier if you generate each word in turn, starting with a consonant. You probably need to revise your loops a bit.
Thank you very much! Problem solved!
Glad I could help.
In the example, I get words: fami wovaw izaber
Instead of the expected: fami wovaw kelasi
Any guesses why this could happen?
You need to start words with a consonant; I think you may be alternating between consonants and vowels.
I tried it, turned: fami wovaw zabera
What sequence of actions if the word begins with a vowel? I just miss it and take the next one.
Since you had "izaber" and now "zabera", it seems you simply skipped the "i". You must not do that, you cannot "burn" numbers given by the LCG, you have to use the number that gave you the "i" and use it to get a consonant. At every word you have to start with a consonant. If you have a mecanism that alternates automatically between vowels and consonants, you have to change it to be able to determine which one to use depending on where you are in the word (odd positions = consonants, even positions = vowels).
Thank you friend! You really helped me with his advice. Really not worth it to skip the letter and use it in number lcg, it was necessary to use a number of the previous.
Yet the problem is solved, thanks again.