Funny Words Generator (Problem 72)

Back to General discussions forum

Gelcsi     2015-05-26 09:13:06
User avatar

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.

Guy Gervais     2015-05-26 17:30:57
User avatar

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.

Gelcsi     2015-05-27 12:37:16
User avatar

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

Guy Gervais     2015-05-27 15:55:26
User avatar

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.

Gelcsi     2015-05-27 17:39:03
User avatar

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?

Guy Gervais     2015-05-27 17:53:31
User avatar

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.

Gelcsi     2015-05-27 18:25:20
User avatar

Thank you very much! Problem solved!

Guy Gervais     2015-05-27 22:09:26
User avatar

Glad I could help.

bear.kruts     2015-06-25 14:04:01
User avatar

In the example, I get words: fami wovaw izaber

Instead of the expected: fami wovaw kelasi

Any guesses why this could happen?

Guy Gervais     2015-06-25 22:25:39
User avatar

You need to start words with a consonant; I think you may be alternating between consonants and vowels.

bear.kruts     2015-06-26 06:05:07
User avatar

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.

Guy Gervais     2015-06-26 10:32:03
User avatar

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).

bear.kruts     2015-06-26 19:32:48
User avatar

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.

Please login and solve 5 problems to be able to post at forum